From fa03f24ff011dfb6623ab9dd6c0f5face3f2d30d Mon Sep 17 00:00:00 2001 From: Gadzhi Kharkharov Date: Sat, 18 Sep 2021 12:06:50 +0300 Subject: [PATCH] add contextual preview to kks-grep --- scripts/kks-grep | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/kks-grep b/scripts/kks-grep index 16893b3..463c133 100755 --- a/scripts/kks-grep +++ b/scripts/kks-grep @@ -5,12 +5,14 @@ # requires: # - ripgrep (https://github.com/BurntSushi/ripgrep) # - fzf (https://github.com/junegunn/fzf) +# - bat (change to your liking) (https://github.com/sharkdp/bat) history_file="$HOME/.cache/kks-grep-history" [ -f "$history_file" ] || touch "$history_file" rg --vimgrep '.+' "$@" | - fzf --height 100% --prompt 'grep> ' --history="$history_file" | + fzf -d ':' --height 100% --prompt 'grep> ' --history="$history_file" \ + --preview='range="$(echo {2}-5 | bc | sed "s/^-.*/0/"):$(echo {2}+20 | bc)"; bat -r "$range" -n --color always -H {2} {1}' | awk -F':' '{print $1 " " "+" $2 ":" $3 }' | xargs -r kks edit