diff --git a/.config/lf/lfrc b/.config/lf/lfrc index ea84fa6d7..0b625fbc8 100644 --- a/.config/lf/lfrc +++ b/.config/lf/lfrc @@ -131,42 +131,54 @@ cmd dupe &{{ # cmd share $curl -F"file=@$fx" https://0x0.snaile.de | xclip -r -selection c -# TODO: Move this to zsh config -cmd fzfsearch ${{ - file="$(find -L $PWD | fzf --header='Searching Filenames' --preview='head -$LINES {} 2>/dev/null || ls -lhpAN --color=always --group-directories-first {}' || true)" +cmd find_file ${{ + file="$(find -L $PWD | fzf --header='Searching Filenames' --preview='head -$LINES \"$(echo {} | cut -f2)\" 2>/dev/null || ls -lhpAN --color=always --group-directories-first {}' || true)" [ -z "$file" ] && return [ -d "$file" ] && lf -remote "send $id cd $file" && return 0 [ -f "$file" ] && lf -remote "send $id select $file" }} -cmd fzftags ${{ +cmd find_tag ${{ file="$(cat $XDG_DATA_HOME/lf/tags | fzf --header='Searching Tags' | sed 's/:.$//' || true)" [ -z "$file" ] && return [ -d "$file" ] && lf -remote "send $id cd $file" && return 0 [ -f "$file" ] && lf -remote "send $id select $file" }} -cmd fzfmarks ${{ +cmd find_mark ${{ file="$(cat $XDG_DATA_HOME/lf/marks | fzf --header='Searching Marks' | cut -b 3- || true)" [ -z "$file" ] && return [ -d "$file" ] && lf -remote "send $id cd $file" && return 0 [ -f "$file" ] && lf -remote "send $id select $file" }} -cmd fzfshortcut ${{ - file="$(cat $XDG_DATA_HOME/lf/dirs | fzf --header='Searching Shortcuts' --preview='echo '{}' | cut -f2 | xargs ls' | cut -f2 )" - [ -z "$file" ] && return - [ -d "$file" ] && lf -remote "send $id cd $file" && return 0 - [ -f "$file" ] && lf -remote "send $id select $file" +cmd find_shortcut ${{ + clear + file="$(\ + fzf --expect=' ' --preview-window right,90% --select-1 --cycle --bind one:accept -q '^' -d "\t" -e -n 1 --with-nth=1 --scheme=history --history="$XDG_DATA_HOME/lf/shortcut_history" --header='Searching Shortcuts' --preview=' + file=$(cut -f2 <<< {}) + if [ -f "$file" ] && [ -r "$file" ]; then + head -$LINES "$file" + elif [ -d "$file" ] && [ -r "$file" ]; then + ls -lhpANX --color=always --group-directories-first "$file" + fi + ' <"$XDG_DATA_HOME/lf/dirs" | + cut -f2 | + tr -d '\n' + )" + + if [ -d "$file" ]; then + lf -remote "send $id cd $file" + return + elif [ -f "$file" ]; then + lf -remote "send $id select $file" + fi }} -# cmd fzfworkon ${{ -# workon -n $(workon | fzf) -# }} -cmd fzfgrep ${{ +cmd find_word ${{ set +ue RG_PREFIX="rg --hidden --column --line-number --no-heading --color=always --smart-case --follow --no-ignore " res="$( FZF_DEFAULT_COMMAND="$RG_PREFIX ''" \ - fzf --bind "change:reload:$RG_PREFIX {q} || true" \ - --ansi --layout=reverse --header 'Searching file contents' |\ - grep -iv -e 'Trash/files' -e 'Trash/info' + fzf --bind "change:reload:$RG_PREFIX {q} || true" \ + --ansi --layout=reverse --header 'Searching file contents' |\ + grep -iv -e 'Trash/files' -e 'Trash/info' )" file="$(realpath "$(echo "$res" | cut -d':' -f1 | sed 's/\\/\\\\/g;s/"/\\"/g')" 2>/dev/null)" row="$(echo "$res" | cut -d':' -f2)" @@ -193,16 +205,16 @@ cmd extract ${{ done }} -cmd set_previewer %{{ +cmd set_previewer &{{ if [ "${1}" = "sixel" ]; then lf -remote "send $id :set sixel; set previewer ~/.config/lf/preview/sixel" - echo 'Previewer set to sixel' + # echo 'Previewer set to sixel' elif [ "${1}" = "ueberzug" ]; then lf -remote "send $id :set cleaner ~/.config/lf/preview/clean; set previewer ~/.config/lf/preview/ueberzug" - echo 'Previewer set to ueberzug' + # echo 'Previewer set to ueberzug' else lf -remote "send $id :set previewer ~/.config/lf/preview/chafa" - echo 'Previewer set to chafa' + # echo 'Previewer set to chafa' fi }} @@ -215,9 +227,9 @@ cmd new_lf_term &{{ &{{ set +u - previewer=sixel + previewer=ueberzug # [ -n "$SCRATCHPAD" ] && previewer=sixel - [ -n "$TMUX" ] && previewer=ueberzug + # [ -n "$TMUX" ] && previewer=ueberzug [ -n "$VIM" ] && previewer=chafa lf -remote "send $id set_previewer $previewer" @@ -238,11 +250,11 @@ map quit map :toggle; down map shell map shell-wait -map a fzfsearch -map t fzftags -map m fzfmarks -map f fzfshortcut -map g fzfgrep +map find_shortcut +map -a find_file +map -t find_tag +map -m find_mark +map -g find_word map "'" mark-load map '"' mark-save map "$" shell @@ -267,8 +279,6 @@ map F find-back map lazygit map $gdu map gg top -map g/ cd "/" -# WARN: do not chain any more maps to g (check shortcutrc) map G bottom map h updir map i :rename; cmd-end # rename from end @@ -287,7 +297,7 @@ map q quit map reload map r :rename # before extension map R $lf -remote "send $id :select \"$(readlink $f)\"" -map set hidden! +map sh :set hidden! map sn :set sortby natural; set info map ss :set sortby size; set info size map st :set sortby time; set info time @@ -312,6 +322,3 @@ map zn set info map zs set info size map zt set info time map za set info size:time - -# Load bookmark shortcuts -source "~/.config/lf/shortcutrc" diff --git a/.config/lf/shortcutrc b/.config/lf/shortcutrc deleted file mode 100644 index 7f75ab653..000000000 --- a/.config/lf/shortcutrc +++ /dev/null @@ -1,18 +0,0 @@ -map gh cd "/home/luca" -map gch cd "/home/luca/.cache" -map gcf cd "/home/luca/.config" -map gdt cd "/home/luca/.local/share" -map gst cd "/home/luca/.local/state" -map gsc cd "/home/luca/.local/bin" -map gse cd "/home/luca/.local/libexec" -map gmn cd "/mnt" -map gco cd "/home/luca/Documents/dev" -map gdl cd "/home/luca/Downloads" -map gdm cd "/home/luca/Documents" -map gdk cd "/home/luca/Desktop" -map gms cd "/home/luca/Music" -map gpc cd "/home/luca/Pictures" -map gvd cd "/home/luca/Videos" -map gdot cd "/home/luca/.local/share/stow/dots" -map glg cd "/home/luca/.local/log" -map gsv cd "/home/luca/.local/sv" diff --git a/.config/lf/test.sh b/.config/lf/test.sh new file mode 100644 index 000000000..523023f0e --- /dev/null +++ b/.config/lf/test.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +clear +file="$(\ +fzf --expect=' ' --select-1 --cycle --bind one:accept -q '^' -e -n1 --scheme=history --history="$XDG_DATA_HOME/lf/shortcut_history" --header='Searching Shortcuts' --preview=' + file=$(cut -f2 <<< "{}") + if [ -f "$file" ] && [ -r "$file" ]; then + head -$LINES "$file" + elif [ -d "$file" ] && [ -r "$file" ]; then + ls -lhpANX --color=always --group-directories-first "$file" + fi + ' <"$XDG_DATA_HOME/lf/dirs" | + cut -f2 | + tr -d '\n' +)" + +if [ -d "$file" ]; then + lf -remote "send $id cd $file" + return +elif [ -f "$file" ]; then + lf -remote "send $id select $file" +fi