From d8b9b13d079b5282e82d83be04b43f57b12ee0d3 Mon Sep 17 00:00:00 2001 From: JacobTravers Date: Wed, 5 Apr 2023 15:34:37 -0700 Subject: [PATCH] apply literal flag according to grep tool --- rc/tools/grep.kak | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/rc/tools/grep.kak b/rc/tools/grep.kak index 6e6246e4..292f2570 100644 --- a/rc/tools/grep.kak +++ b/rc/tools/grep.kak @@ -9,9 +9,23 @@ define-command -params .. -docstring %{ All optional arguments are forwarded to the grep utility Passing no argument will perform a literal-string grep for the current selection } grep %{ evaluate-commands %sh{ - if [ $# -eq 0 ]; then - set -- -F "${kak_selection}" - fi + if [ $# -eq 0 ]; then + IFS=" " greptool=$( + set -- $kak_opt_grepcmd + echo "$1" + ) + case "$greptool" in + ag | grep | rg | ripgrep | ugrep | ug) + set -- -F "${kak_selection}" + ;; + ack ) + set -- -Q "${kak_selection}" + ;; + *) + set -- "${kak_selection}" + ;; + esac + fi output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-grep.XXXXXXXX)/fifo mkfifo ${output}