Skip to content

Instantly share code, notes, and snippets.

@iamFIREcracker
Created January 31, 2012 13:12
Show Gist options
  • Save iamFIREcracker/1710416 to your computer and use it in GitHub Desktop.
Save iamFIREcracker/1710416 to your computer and use it in GitHub Desktop.
Let me google clipboard for you!
#!/usr/bin/env bash
# Utility script which googles for the data contained inside positional
# arguments or for everything stored inside the WM clipboard.
#
# If the content of either positional argumets or clipboard starts with
# http,ftp,ecc (which means it is already a valid url), then skip the
# url-stuffing bit.
#
# Depends on xclip and xdg-open
[ $# != 0 ] && data="$@" || data=$(xclip -o)
if [[ "${data}" =~ ^(http|ftp|telnet) ]] ; then
# do nothing, data is already an url resource
url=${data}
else
url="http://www.google.com/search?&q=${data}"
fi
xdg-open "${url}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment