gg 373 B

1234567891011121314151617181920212223
  1. #!/bin/sh
  2. # ggf, stands for Git Grep
  3. # find a file and line number
  4. # requires pick(1) to be installed
  5. query="$1"
  6. flag="-n"
  7. if test "$1" = "-n"; then
  8. flag=""
  9. query="$2"
  10. fi
  11. if test "$1" = "+"; then
  12. query="$2"
  13. fi
  14. full=`git grep $flag $query | pick`
  15. file=`echo "$full" | cut -d : -f 1-2`
  16. if test "$1" = "+"; then
  17. echo $file | sed -e "s/:/ +/g"
  18. else
  19. echo "$file"
  20. fi