Here's a useful shell procedure:
git grep --color=auto -lz "$1" | xargs -r0 sh -c "vi +/\"$1\" \"\$@\" < /dev/tty"
git grep is a very effective way to run a recursive
grep over a git
repository, or part of a git repository (by default, it limits its search to
the sub-tree you are currently sitting in). I quite often find myself wanting
to edit every file that matched a search, and so wrote this snippet.
/dev/tty-ugliness is to work around
vi complaining that it's standard
input was set to
xargs has a command,
sorts this out; GNU
xargs doesn't, but the manual suggests the above portable
workaround. This marks the first time a BSD tool has had a feature I've wanted
and the GNU equivalent doesn't.