123456789101112131415161718192021222324252627 |
- #!/bin/sh
- # ggt, stands for Git Grep Type
- # find a file and line number but type the query inside of pick(1)
- # CAVEAT: Loading grep each time is slow. If you use a faster grep
- # it may be faster!
- # requires pick(1) to be installed
- GREP="grep"
- query="$1"
- flag="-n"
- if test "$1" = "-n"; then
- flag=""
- query="$2"
- fi
- if test "$1" = "+"; then
- query="$2"
- fi
- full=`git ls-files | xargs ${GREP} $flag "" | pick`
- file=`echo "$full" | cut -d : -f 1-2`
- if test "$1" = "+"; then
- echo $file | sed -e "s/:/ +/g"
- else
- echo "$file"
- fi
|