Skip to content

Instantly share code, notes, and snippets.

@inooid
Created March 16, 2015 09:34
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inooid/ce1da5696432710e540b to your computer and use it in GitHub Desktop.
Save inooid/ce1da5696432710e540b to your computer and use it in GitHub Desktop.
Google command to search on Google from the command line (Mac OS X)
# Command to open the webbrowser and immediately start searching
# for the right keyword.
#
# Usage:
# $ google test query
# $ => Opens the browser on http://www.google.com/search?q=test+query
#
google()
{
local s="$_"
local query=
case "$1" in
'') ;;
that) query="search?q=${s//[[:space:]]/+}" ;;
*) s="$*"; query="search?q=${s//[[:space:]]/+}" ;;
esac
open /Applications/Google\ Chrome.app/ "http://www.google.com/${query}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment