12345678910111213141516171819202122232425 |
- #!/bin/sh
- # fgt, stands for Find 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
- query="$1"
- flag="-n"
- if test "$1" = "-n"; then
- flag=""
- query="$2"
- fi
- if test "$1" = "+"; then
- query="$2"
- fi
- full=`find . -type f -exec 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
|