top | item 13065670

Show HN: Anycomplete

390 points| nathancahill | 9 years ago |github.com | reply

85 comments

order
[+] stroebjo|9 years ago|reply
This uses the Google Autocomplete API which seems a bit risky to use [0] and according to this Google blog post should be already shut down [1]. Do you have any newer information on how reliable the API is?

[0]: http://stackoverflow.com/questions/6428502/google-search-aut... [1]: https://webmasters.googleblog.com/2015/07/update-on-autocomp...

[+] AlphaWeaver|9 years ago|reply
Instructions are also included to use DuckDuckGo.
[+] jxy|9 years ago|reply
If you have your shell ready,

    curl -sS 'https://www.google.com/complete/search?client=hp&hl=en&xhr=t&q=aurora' \
        | json_pp | sed -nE '/<\/?b>/{s```g;s`"|,|^ *``g;p}'
[+] jsrn|9 years ago|reply
Nice!

To run this with macOS, I had to use the GNU version of sed. I installed it with

    $ brew install gnu-sed
And it is then called with 'gsed' instead of 'sed'.

As an avid Perl programmer, I had json_pp in my $PATH - for everyone else - it is here: https://metacpan.org/pod/JSON::PP

You can install it with cpanm:

    $ cpanm JSON::PP
If you don't have cpanm, you can install it with

    $ curl -L https://cpanmin.us | perl - App::cpanminus
The modified command line from above then becomes:

    $ curl -sS 'https://www.google.com/complete/search?client=hp&hl=en&xhr=t&q=aurora' \
        | json_pp | gsed -nE '/<\/?b>/{s```g;s`"|,|^ *``g;p}'
Here is a little Bash function to encapsulate this:

    $ function c() { curl -sS "https://www.google.com/complete/search?client=hp&hl=en&xhr=t&q=$1" | json_pp | gsed -nE '/<\/?b>/{s```g;s`"|,|^ *``g;p}'; }
Which then allows you to use it like this:

    $ c hacker
    hacker news
    hacker typer
    hackerrank
    hackerman
    hackers movie
    hacker fare
    hackerone
    hackers cast
    hacker pschorr
For spaces in your query, use a '+':

    $ c New+York
    new york times
    new york and company
    new york giants
    new york post
    new york daily news
    new york weather
[+] devoply|9 years ago|reply
I have learned the hard way never to type stuff like this into a shell because I might not like the results. It looks fine, but never again. ;)
[+] mooman219|9 years ago|reply
Had this idea a while back: I really enjoyed auto complete in my IDE and configurable expansions and I wanted that everywhere. I threw together an app to run in the background to keep track of the last word I typed and manage suggestions when I hit a hotkey. Read from a local dictionary, used basic usage frequency and levenshtein distance to recommend, pretty straightforward hacked together in an afternoon project. I could see Anycomplete using a more local suggestion list instead of relying on Google.

Ideally it showed a drop down under where you're typing much like most IDEs would, but support was shotty at best. I really wish there were more OS level hooks for this sort of thing, or a more standardized way to understand what the user is typing and where, but that's not something I ever expect to happen. My app was basically a keylogger while the one in the post is more like a separate entity altogether.

[+] lbotos|9 years ago|reply
I just tried Hammerspoon for the first time this week and it's really, really powerful. Currently working on an automation suite for a bunch of tedious "micro-workflows" that I deal with on a daily basis.
[+] _vya7|9 years ago|reply
Really enjoying seeing a lot of new projects based on Hammerspoon. And very glad for the people who created it, because maintaining the precursor was a daunting job and took too much of my time and gave me too much stress.
[+] mooman219|9 years ago|reply
For windows users, I recommend AutoHotkey
[+] ryanSrich|9 years ago|reply
Is there a place to find inspiration or other examples of Hammerspoon extensions? Just installed and wrote a few simple scripts, but having a hard time coming up with anything groundbreaking that I'd want to build.
[+] hossbeast|9 years ago|reply
And by "Anywhere", you mean, on macOs
[+] wingerlang|9 years ago|reply
Anywhere within a targeted OS is not a valid description? It clearly shows that it is macOS.
[+] joshuak|9 years ago|reply
Universal autocomplete based on a local index of words? That would be great!

Universal autocomplete via google api? Hmm, something to think about.

1) Keyloggers

2) Filter bubbles

3) Offline tax

[+] sytringy05|9 years ago|reply
That's pretty cool, but I'm fairly certain that sooner or later I would end up googling my password.
[+] Aldo_MX|9 years ago|reply
What's the matter? Passwords are intended to be disposable, here, have one: xAKi2It6XJK7QJR1ROXFK7xmjV6kn6DNÑJU7Pu9hA7OS
[+] pdaddyo|9 years ago|reply
This is great, thanks for sharing. I've opened a pull request (#5) with a tweak I made here - hold shift whilst choosing an option to actually show the google results instead of pasting. Hammerspoon looks fantastic, can't wait to automate even more!
[+] milge|9 years ago|reply
I built something like this many moons ago for browser history. A service would run on your machine to aggregate your browser history. Typing "http://" anywhere on your machine would pop up a dialog with your history of most recently visited sites. I wonder if browsers have gotten better with APIs for web history and if it's any easier in windows. System-wide keystrokes had to be checked with win32 calls which could set off antivirus alarms. Keep up the good work. Maybe this will inspire me to see if things have gotten better.
[+] rm_-rf_slash|9 years ago|reply
This is pretty cool, but it would really impress me if it could autocomplete facts based on contexts. I wish I could open a text editor and begin writing while Anycomplete(-plus) crawled the web for links to factual data based on the writing so far. Otherwise the context switching is time-consuming and discouraging.
[+] kayamon|9 years ago|reply
Google actually already does this, based on what you just searched for.

Search for "swing", then in the search box, delete that and type in "play". It'll auto-complete with something like "playground swing".

Now in a new tab, search for "music". Then delete that and search for "play". You'll get different results.

(doesn't work with the browser search box, has to be the one in the page itself)

[+] Gracana|9 years ago|reply
That seems both really cool and absolutely terrifying. Automatically find references when writing a tutorial? Hell yes! Automatically find references to support an argument you've decided to make? Hmm... maybe not a win for journalism.

[edit] Actually, I guess the way you described it, it could go the other way. You start writing some argument, and google shows you some stats that show you're wrong, or something. That would be neat.

[+] mmanfrin|9 years ago|reply
Spotlight already does this. Type in 'aurora borealis' and it'll pull a wiki blurb (or maybe definition).
[+] jxy|9 years ago|reply
DEVONsphere does something close to that. It does a simple keyword analysis and searches local/web. But what you are describing is more of a personal research assistant that's way beyond what today's system can do.
[+] ChuckMcM|9 years ago|reply
Nicely done. It will be interesting to see if this impacts your robot score when using Google. There was a blow up a while ago where people used the completion API to fish for trending searches and front run the Google News API and get stories onto the news page.
[+] rootlocus|9 years ago|reply
This is very useful for people like me who google words to check the correct spelling. Any plans on adding support for definitions / explanations of words? Something like the result of "define aurora" google query.
[+] willcodeforfoo|9 years ago|reply
Interesting, didn't know Hammerspoon had this "chooser" functionality. I guess with enough Lua you could replace Alfred!
[+] smnplk|9 years ago|reply
nope, I am not sending my keystrokes anywhere
[+] justinzollars|9 years ago|reply
How does one get the output into an application? Do I have to use clipboard? Clicking command 1 simply closes the app
[+] nathancahill|9 years ago|reply
Please open an issue on Github with the content of your Hammerspoon log (Hammer menu > Console...).
[+] thecity2|9 years ago|reply
Followed the installation steps, but it doesn't seem to work for me.
[+] nathancahill|9 years ago|reply
Can you open an issue with the content of the Hammerspoon log (Hammer menu > Console...)
[+] erelde|9 years ago|reply
Would love to have that inside something like drun or rofi.