Skip to content

Commit 007d06a

Browse files
bbolligitster
authored andcommitted
contrib/git-jump: allow to configure the grep command
Add the configuration option "jump.grepCmd" that allows to configure the command that is used to search in grep mode. This allows the users of git-jump to use ag(1) or ack(1) as search engines. Signed-off-by: Beat Bolli <[email protected]> Reviewed-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 89ea799 commit 007d06a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

contrib/git-jump/README

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ git jump grep foo_bar
6363
# same as above, but case-insensitive; you can give
6464
# arbitrary grep options
6565
git jump grep -i foo_bar
66+
67+
# use the silver searcher for git jump grep
68+
git config jump.grepCmd "ag --column"
6669
--------------------------------------------------
6770

6871

contrib/git-jump/git-jump

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ diff: elements are diff hunks. Arguments are given to diff.
1111
1212
merge: elements are merge conflicts. Arguments are ignored.
1313
14-
grep: elements are grep hits. Arguments are given to grep.
14+
grep: elements are grep hits. Arguments are given to git grep or, if
15+
configured, to the command in `jump.grepCmd`.
1516
1617
ws: elements are whitespace errors. Arguments are given to diff --check.
1718
EOF
@@ -50,7 +51,9 @@ mode_merge() {
5051
# but let's clean up extra whitespace, so they look better if the
5152
# editor shows them to us in the status bar.
5253
mode_grep() {
53-
git grep -n "$@" |
54+
cmd=$(git config jump.grepCmd)
55+
test -n "$cmd" || cmd="git grep -n"
56+
$cmd "$@" |
5457
perl -pe '
5558
s/[ \t]+/ /g;
5659
s/^ *//;

0 commit comments

Comments
 (0)