Created
March 1, 2014 17:55
-
-
Save pesterhazy/9294048 to your computer and use it in GitHub Desktop.
Search your git repository using ag (the silver searcher)
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
#!/bin/bash | |
# Put additional ignore patterns (one by line) in .grepignore | |
# | |
git-ag () { | |
if [[ "$1" = "-a" ]] | |
then | |
all=1 | |
shift | |
else | |
all=0 | |
fi | |
pattern="$1" | |
shift | |
if [[ "$all" = 1 ]] | |
then | |
git ls-files -- "$@" | xargs -d "\n" ag -S "$pattern" | |
else | |
git ls-files -- "$@" | grep -vf .grepignore | xargs -d "\n" ag -S "$pattern" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment