Skip to content

Instantly share code, notes, and snippets.

@eliask
Created December 1, 2016 07:26
Show Gist options
  • Save eliask/79af8dbb8737d640da24f5e4892c0b97 to your computer and use it in GitHub Desktop.
Save eliask/79af8dbb8737d640da24f5e4892c0b97 to your computer and use it in GitHub Desktop.
Auto-complete from command-line (bash) using Google Autocomplete API.
function c() {
url='https://www.google.com/complete/search?client=hp&hl=en&xhr=t'
# NB: user-agent must be specified to get back UTF-8 data!
curl -H 'user-agent: Mozilla/5.0' -sSG --data-urlencode "q=$*" "$url" |
jq -r .[1][][0] |
sed 's,</\?b>,,g'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment