{"thread":{"id":"47148","subject":"[PATCH] contrib/git-jump: allow to configure the grep command","startedAt":"2017-11-09T20:39:22Z","lastAt":"2017-11-09T20:39:22Z","messageCount":1,"participants":["Beat Bolli"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"332134","messageId":"20171109203031.25227-1-dev+git@drbeat.li","threadId":"47148","inReplyTo":null,"subject":"[PATCH] contrib/git-jump: allow to configure the grep command","fromName":"Beat Bolli","fromEmail":"dev+git@drbeat.li","sentAt":"2017-11-09T20:30:31Z","receivedAt":"2017-11-09T20:39:22Z","isPatch":true,"sender":{"key":"dev+git@drbeat.li","avatar":"https://avatars.githubusercontent.com/u/21444?v=4"},"body":"Add the configuration option \"jump.grepCmd\" that allows to configure the\ncommand that is used to search in grep mode. This allows the users of\ngit-jump to use ag(1) or ack(1) as search engines.\n\nSigned-off-by: Beat Bolli <dev+git@drbeat.li>\n---\n contrib/git-jump/README   | 3 +++\n contrib/git-jump/git-jump | 7 +++++--\n 2 files changed, 8 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/git-jump/README b/contrib/git-jump/README\nindex 225e3f095..9f58d5db8 100644\n--- a/contrib/git-jump/README\n+++ b/contrib/git-jump/README\n@@ -63,6 +63,9 @@ git jump grep foo_bar\n # same as above, but case-insensitive; you can give\n # arbitrary grep options\n git jump grep -i foo_bar\n+\n+# use the silver searcher for git jump grep\n+git config jump.grepCmd \"ag --column\"\n --------------------------------------------------\n \n \ndiff --git a/contrib/git-jump/git-jump b/contrib/git-jump/git-jump\nindex 427f206a4..80ab0590b 100755\n--- a/contrib/git-jump/git-jump\n+++ b/contrib/git-jump/git-jump\n@@ -11,7 +11,8 @@ diff: elements are diff hunks. Arguments are given to diff.\n \n merge: elements are merge conflicts. Arguments are ignored.\n \n-grep: elements are grep hits. Arguments are given to grep.\n+grep: elements are grep hits. Arguments are given to git grep or, if\n+      configured, to the command in `jump.grepCmd`.\n \n ws: elements are whitespace errors. Arguments are given to diff --check.\n EOF\n@@ -50,7 +51,9 @@ mode_merge() {\n # but let's clean up extra whitespace, so they look better if the\n # editor shows them to us in the status bar.\n mode_grep() {\n-\tgit grep -n \"$@\" |\n+\tcmd=$(git config jump.grepCmd)\n+\ttest -n \"$cmd\" || cmd=\"git grep -n\"\n+\t$cmd \"$@\" |\n \tperl -pe '\n \ts/[ \\t]+/ /g;\n \ts/^ *//;\n-- \n2.15.0.rc1.299.gda03b47c3\n\n"}]}