Create a gist now

Instantly share code, notes, and snippets.

find++
# "Install" (I use that term loosely)
#
# - Paste the function below in your .bashrc / .profile / .zshrc / etc.
#
# Usage: find /usr/local -type [m|g] -name [KEYWORD]
#
# -type m : google maps search
# -type g : google search
#
# all other types pass through to find
#
# Notes:
# Tested on Ubuntu with ZSH. Comment's, suggestions, etc. welcome.
function find {
if [ `uname -s` = "Darwin" ]; then
$browser="open"
fi
test "$browser" || browser=`which chromium-browser`
test "$browser" || browser=`which google-chrome`
test "$browser" || browser=`which firefox`
query="`echo "$@" | sed -e 's:^[a-z\/\~\.]* ::' -e 's/-type [mg]//' -e 's/-name//'`"
if [[ $@ =~ "-type m" ]]; then
$browser "http://maps.google.com/?q=$query" 2>&1 > /dev/null &
elif [[ $@ =~ "-type g" ]]; then
$browser "http://www.google.com/search?q=$query" 2>&1 > /dev/null &
else
/usr/bin/find $@
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment