r4888 - developers/werner/bin
werner at docs.openmoko.org
werner at docs.openmoko.org
Thu Jan 15 01:21:57 CET 2009
Author: werner
Date: 2009-01-15 01:21:55 +0100 (Thu, 15 Jan 2009)
New Revision: 4888
Added:
developers/werner/bin/gg
Log:
Run a vi search on the files found with git grep.
Added: developers/werner/bin/gg
===================================================================
--- developers/werner/bin/gg (rev 0)
+++ developers/werner/bin/gg 2009-01-15 00:21:55 UTC (rev 4888)
@@ -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
+vi -c /"`nondash \"$@\"`" `git grep -l "$@"`
Property changes on: developers/werner/bin/gg
___________________________________________________________________
Name: svn:executable
+ *
More information about the commitlog
mailing list