Skip to content

Instantly share code, notes, and snippets.

@jmervine
Last active December 21, 2015 02:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmervine/6232984 to your computer and use it in GitHub Desktop.
Save jmervine/6232984 to your computer and use it in GitHub Desktop.
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