Date:2012-07-26 17:35:37 (7 years 1 month ago)
Author:Werner Almesberger
Commit:f44032e1d0f137807d2246d9a79ac273acf17b75
Message:bin/gg: moved over from svn.openmoko.org/developers/werner/bin/gg

Files: bin/gg (1 diff)

Change Details

bin/gg
1#!/bin/sh
2#
3# git grep through a tree, list the hits, then set up vi to go through the
4# files we found, searching for the expression.
5#
6# usage: gg [grep_options] search_expression
7#
8
9nondash()
10{
11    while [ ! -z "$*" ]; do
12    if [ "${1#-}" = "$1" ]; then
13        echo "$1"
14        return
15    fi
16    shift
17    done
18}
19
20#
21# the "cat" here serves two purposes:
22# 1) keep "git grep" from truncating long lines
23# 2) keep "git grep" from using a pager, which would result in waiting twice
24# for user input at the end, which is confusing
25#
26git grep "$@" | cat
27echo -n '[Enter to vi] '
28read x
29${GG_EDITOR:-vi} -c /"`nondash \"$@\"`" `git grep -l "$@"`

Archive Download the corresponding diff file

Branches:
master



interactive