From 68b761a883051b21ecef260ce847a6d97edbab71 Mon Sep 17 00:00:00 2001 From: Luca Bilke Date: Wed, 31 Jan 2024 18:31:31 +0100 Subject: [PATCH] update fzfgrep command in lf --- .config/lf/lfrc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.config/lf/lfrc b/.config/lf/lfrc index 5e6480e5..5ae344a8 100644 --- a/.config/lf/lfrc +++ b/.config/lf/lfrc @@ -116,14 +116,24 @@ cmd fzfshortcut ${{ [ -f $file ] && lf -remote "send $id select $file" }} cmd fzfgrep ${{ - RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case " + RG_PREFIX="rg --hidden --column --line-number --no-heading --color=always --smart-case " res="$( FZF_DEFAULT_COMMAND="$RG_PREFIX ''" \ fzf --bind "change:reload:$RG_PREFIX {q} || true" \ - --ansi --layout=reverse --header 'Search in files' \ - | cut -d':' -f1 | sed 's/\\/\\\\/g;s/"/\\"/g' + --ansi --layout=reverse --header 'Search in files' |\ + grep -iv -e 'Trash/files' -e 'Trash/info' )" - [ -n "$res" ] && lf -remote "send $id select \"$res\"" + file="$(echo $res | cut -d':' -f1 | sed 's/\\/\\\\/g;s/"/\\"/g')" + row="$(echo $res | cut -d':' -f2)" + column="$(echo $res | cut -d':' -f3)" + if [ -n "$res" ]; then + lf -remote "send ${id} select '$file'" + if [ "$EDITOR" = "nvim" ] || [ "$EDITOR" = "vim" ]; then + lf -remote "send $id \$$EDITOR '$file' +'call cursor($row, $column)'" + else + lf -remote "send $id \$$EDITOR '$file'" + fi + fi }} cmd extract ${{