From 01fd6552af6b909f533d5cd8bf3a5385d4e35215 Mon Sep 17 00:00:00 2001 From: Willow Barraco Date: Sun, 10 Sep 2023 11:30:05 +0200 Subject: [PATCH] tools/git: add git grep using existing grep tool --- rc/tools/git.kak | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rc/tools/git.kak b/rc/tools/git.kak index 18796e4e..440b6571 100644 --- a/rc/tools/git.kak +++ b/rc/tools/git.kak @@ -66,9 +66,10 @@ define-command -params 1.. \ show-diff status update-diff + grep } -shell-script-candidates %{ if [ $kak_token_to_complete -eq 0 ]; then - printf "add\nrm\nreset\nblame\ncommit\ncheckout\ndiff\nhide-blame\nhide-diff\nlog\nnext-hunk\nprev-hunk\nshow\nshow-branch\nshow-diff\ninit\nstatus\nupdate-diff\n" + printf "add\nrm\nreset\nblame\ncommit\ncheckout\ndiff\nhide-blame\nhide-diff\nlog\nnext-hunk\nprev-hunk\nshow\nshow-branch\nshow-diff\ninit\nstatus\nupdate-diff\ngrep\n" else case "$1" in commit) printf -- "--amend\n--no-edit\n--all\n--reset-author\n--fixup\n--squash\n"; git ls-files -m ;; @@ -347,6 +348,15 @@ define-command -params 1.. \ reset|checkout) run_git_cmd "$@" ;; + grep) + shift + enquoted="$(printf '"%s" ' "$@")" + printf %s "try %{ + set-option current grepcmd 'git grep -n' + grep $enquoted + set-option current grepcmd '$kak_opt_grepcmd' + }" + ;; *) printf "fail unknown git command '%s'\n" "$1" exit