Fix the J keybinding in lf

Now it's easy to jump to your bookmarked directories in lf, just press J and enter the shortcut.
This commit is contained in:
Rokosun 2025-01-27 07:42:01 +00:00 committed by GitHub
parent c43f390f07
commit 7db5655bf8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -148,9 +148,22 @@ cmd bulkrename ${{
lf -remote "send $id unselect"
}}
cmd shortcutjump ${{
set -f
clear; tput cup $(($(tput lines)/3))
tmp="$(mktemp)" && trap 'rm "$tmp"' EXIT || exit
sed 's/\s*#.*//; /^$/d' "${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs" > "$tmp"
choice=$(cat "$tmp" | fzf --layout=reverse --height 40% --listen --no-ignore-case --tiebreak=begin,chunk -n1 \
--bind result:transform:"grep -q '^{q}\s' \"$tmp\" && [ \$(grep '^{q}\S*\s' \"$tmp\" | wc -l) -eq 1 ] && echo accept" | \
sed 's/\S\+\s\+//')
[ -z "$choice" ] && exit
path=$(eval printf '%s' \"$choice\")
lf -remote "send $id cd $path"
}}
# Bindings
map <c-f> $lf -remote "send $id select \"$(fzf)\""
map J $lf -remote "send $id cd $(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf)"
map J shortcutjump
map H cd ~
map g top
map D delete