1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-07 18:56:10 +02:00

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>
This commit is contained in:
Beat Bolli 2017-11-20 00:05:36 +01:00 committed by Junio C Hamano
parent 89ea799ffc
commit 007d06aa57
2 changed files with 8 additions and 2 deletions

View File

@ -63,6 +63,9 @@ git jump grep foo_bar
# same as above, but case-insensitive; you can give
# arbitrary grep options
git jump grep -i foo_bar
# use the silver searcher for git jump grep
git config jump.grepCmd "ag --column"
--------------------------------------------------

View File

@ -11,7 +11,8 @@ diff: elements are diff hunks. Arguments are given to diff.
merge: elements are merge conflicts. Arguments are ignored.
grep: elements are grep hits. Arguments are given to grep.
grep: elements are grep hits. Arguments are given to git grep or, if
configured, to the command in `jump.grepCmd`.
ws: elements are whitespace errors. Arguments are given to diff --check.
EOF
@ -50,7 +51,9 @@ mode_merge() {
# but let's clean up extra whitespace, so they look better if the
# editor shows them to us in the status bar.
mode_grep() {
git grep -n "$@" |
cmd=$(git config jump.grepCmd)
test -n "$cmd" || cmd="git grep -n"
$cmd "$@" |
perl -pe '
s/[ \t]+/ /g;
s/^ *//;