From 7db5655bf8f5dbf9dd5924d4ff293e0912f012a6 Mon Sep 17 00:00:00 2001 From: Rokosun <79040025+futureisfoss@users.noreply.github.com> Date: Mon, 27 Jan 2025 07:42:01 +0000 Subject: [PATCH] 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. --- .config/lf/lfrc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.config/lf/lfrc b/.config/lf/lfrc index 5598a307..1b390fab 100644 --- a/.config/lf/lfrc +++ b/.config/lf/lfrc @@ -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 $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