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 <dev+git@drbeat.li> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Beat Bolli committed
Nov 20, 2017 at 00:05 UTC
007d06aa57e673c95da583d2afa30bb14fb69e28
2 files changed
+8
-2
contrib/git-jump/README
+3
@@ -63,6 +63,9 @@ git jump grep foo_bar
63
# same as above, but case-insensitive; you can give
64
# arbitrary grep options
65
git jump grep -i foo_bar
66
+
67
+# use the silver searcher for git jump grep
68
+git config jump.grepCmd "ag --column"
69
--------------------------------------------------
70
71
contrib/git-jump/git-jump
+5
-2
@@ -11,7 +11,8 @@ diff: elements are diff hunks. Arguments are given to diff.
11
12
merge: elements are merge conflicts. Arguments are ignored.
13
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`.
16
17
ws: elements are whitespace errors. Arguments are given to diff --check.
18
EOF
@@ -50,7 +51,9 @@ mode_merge() {
51
# but let's clean up extra whitespace, so they look better if the
52
# editor shows them to us in the status bar.
53
mode_grep() {
53
- git grep -n "$@" |
54
+ cmd=$(git config jump.grepCmd)
55
+ test -n "$cmd" || cmd="git grep -n"
56
+ $cmd "$@" |
57
perl -pe '
58
s/[ \t]+/ /g;
59
s/^ *//;