1
0
Fork 0

update fzfgrep command in lf

This commit is contained in:
Luca Bilke 2024-01-31 18:31:31 +01:00
parent 0165765cfb
commit 68b761a883

View file

@ -116,14 +116,24 @@ cmd fzfshortcut ${{
[ -f $file ] && lf -remote "send $id select $file" [ -f $file ] && lf -remote "send $id select $file"
}} }}
cmd fzfgrep ${{ 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="$( res="$(
FZF_DEFAULT_COMMAND="$RG_PREFIX ''" \ FZF_DEFAULT_COMMAND="$RG_PREFIX ''" \
fzf --bind "change:reload:$RG_PREFIX {q} || true" \ fzf --bind "change:reload:$RG_PREFIX {q} || true" \
--ansi --layout=reverse --header 'Search in files' \ --ansi --layout=reverse --header 'Search in files' |\
| cut -d':' -f1 | sed 's/\\/\\\\/g;s/"/\\"/g' 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 ${{ cmd extract ${{