Created
November 11, 2015 18:14
-
-
Save imightbeamy/1da930eef3c18ba655d3 to your computer and use it in GitHub Desktop.
Smart Grep switches between regular and git grep based on your directory.
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
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