1
0
Fork 0

lf: performance and usability improvements in fzf

This commit is contained in:
Luca Bilke 2024-07-15 17:37:48 +02:00
parent b16b3b6bbc
commit c8d8c4674c
Signed by: luca
GPG Key ID: F6E11C9BAA7C82F5
1 changed files with 11 additions and 4 deletions

View File

@ -118,6 +118,7 @@ cmd fzf ${{
clear
file="$(eval "$input" | fzf \
--exact \
--query "$query" \
--delimiter "$delimiter" \
--nth="$field" \
@ -151,15 +152,21 @@ for cmd in bat batcat head; do
done
res="$(
FZF_DEFAULT_COMMAND="$RG_PREFIX ." SEDPATTERN='s/\\/\\\\/g;s/"/\\"/g' SHELL="sh" \
fzf --bind "change:reload:${RG_PREFIX} {q} || true" \
--preview-window="right,50%" --preview="
fzf \
--ansi \
--exact \
--bind "change:reload:${RG_PREFIX} {q} || true" \
--preview-window="right,50%" \
--preview="
file=\$(realpath \"\$(echo {} | cut -d: -f1 | sed \"\${SEDPATTERN}\")\" 2>/dev/null)
case '$cmd' in
head) head -n 300 \"\$file\" ;;
bat*) '$cmd' --color=always --italic-text=always --style=plain --pager=never \
--tabs=4 --theme=base16 --line-range :300 \"\$file\" ;;
esac
" --ansi --layout=reverse --header 'Searching file contents'
" \
--layout=reverse \
--header 'Searching file contents'
)"
file="$(realpath "$(echo "$res" | cut -d':' -f1 | sed 's/\\/\\\\/g;s/"/\\"/g')" 2>/dev/null)"
row="$(echo "$res" | cut -d':' -f2)"
@ -245,7 +252,7 @@ map <a-enter> shell-wait
map <tab><tab> find_project
map <tab>t fzf 'Tags' 'cat $XDG_DATA_HOME/lf/tags 2>/dev/null' ':' '1' '1' '50%'
map <tab>m fzf 'Marks' 'cat $XDG_DATA_HOME/lf/marks 2>/dev/null' ':' '1' '2' '85%' '^'
map <tab>f fzf 'Files' 'find -L $PWD' ':' '1' '1' '50%'
map <tab>f fzf 'Files' 'fd -L --full-path $PWD' ':' '1' '1' '50%'
map <tab>g find_word
map "'" mark-load
map '"' mark-remove