Created
January 31, 2012 13:12
-
-
Save iamFIREcracker/1710416 to your computer and use it in GitHub Desktop.
Let me google clipboard for you!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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