Skip to content

Instantly share code, notes, and snippets.

@imightbeamy
Created November 11, 2015 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imightbeamy/1da930eef3c18ba655d3 to your computer and use it in GitHub Desktop.
Save imightbeamy/1da930eef3c18ba655d3 to your computer and use it in GitHub Desktop.
Smart Grep switches between regular and git grep based on your directory.
STANDARD_GREP=`which grep`
alias grep='smart_grep'
function smart_grep {
if [ -d ".git" ]; then
git grep "${@:1}"
else
$STANDARD_GREP "$@"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment