mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2024-11-22 01:48:26 +02:00
bin/gg: moved over from svn.openmoko.org/developers/werner/bin/gg
This commit is contained in:
parent
4edc0da744
commit
f44032e1d0
29
bin/gg
Executable file
29
bin/gg
Executable file
@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# git grep through a tree, list the hits, then set up vi to go through the
|
||||||
|
# files we found, searching for the expression.
|
||||||
|
#
|
||||||
|
# usage: gg [grep_options] search_expression
|
||||||
|
#
|
||||||
|
|
||||||
|
nondash()
|
||||||
|
{
|
||||||
|
while [ ! -z "$*" ]; do
|
||||||
|
if [ "${1#-}" = "$1" ]; then
|
||||||
|
echo "$1"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# the "cat" here serves two purposes:
|
||||||
|
# 1) keep "git grep" from truncating long lines
|
||||||
|
# 2) keep "git grep" from using a pager, which would result in waiting twice
|
||||||
|
# for user input at the end, which is confusing
|
||||||
|
#
|
||||||
|
git grep "$@" | cat
|
||||||
|
echo -n '[Enter to vi] '
|
||||||
|
read x
|
||||||
|
${GG_EDITOR:-vi} -c /"`nondash \"$@\"`" `git grep -l "$@"`
|
Loading…
Reference in New Issue
Block a user