# Basic vars set shellopts '-eu' set ifs "\n" set scrolloff 10 set icons set hidden true set drawbox true set roundbox true set watch true # files other programs add or remove (remage, downloads, waldl) show up without polling set previewer '~/.config/lf/scope' set preload true set autoquit true # cmds/functions cmd open ${{ set -f case $(file --mime-type "$(readlink -f "$f")" -b) in image/vnd.djvu|application/pdf|application/postscript) setsid -f zathura $fx >/dev/null 2>&1 ;; text/*|application/json|inode/x-empty|application/x-subrip) $EDITOR $fx;; image/x-xcf) setsid -f gimp "$f" >/dev/null 2>&1 ;; # one image = remage on its whole directory, starting there; a selection = just those. # Images marked in remage (m) become the selection here. image/*) setsid -f ~/.config/lf/remage-pick $fx >/dev/null 2>&1 ;; audio/*|video/x-ms-asf) mpv --audio-display=no $fx ;; video/*) setsid -f mpv $fx -quiet >/dev/null 2>&1 ;; application/vnd.djvu|application/epub*) setsid -f zathura $fx >/dev/null 2>&1 ;; application/pgp-encrypted) $EDITOR $fx ;; application/vnd.openxmlformats-officedocument.wordprocessingml.document|application/vnd.oasis.opendocument.text|application/vnd.openxmlformats-officedocument.spreadsheetml.sheet|application/vnd.oasis.opendocument.spreadsheet|application/vnd.oasis.opendocument.spreadsheet-template|application/vnd.openxmlformats-officedocument.presentationml.presentation|application/vnd.oasis.opendocument.presentation-template|application/vnd.oasis.opendocument.presentation|application/vnd.ms-powerpoint|application/vnd.oasis.opendocument.graphics|application/vnd.oasis.opendocument.graphics-template|application/vnd.oasis.opendocument.formula|application/vnd.oasis.opendocument.database) setsid -f libreoffice $fx >/dev/null 2>&1 ;; application/octet-stream) case ${f##*.} in doc|docx|xls|xlsx|odt|ppt|pptx) setsid -f libreoffice $fx >/dev/null 2>&1 ;; ghw) setsid -f gtkwave "$f" >/dev/null 2>&1 ;; ts) setsid -f mpv $fx -quiet >/dev/null 2>&1 ;; *) setsid -f zathura $fx >/dev/null 2>&1 ;; esac ;; *) for f in $fx; do setsid -f xdg-open "$f" >/dev/null 2>&1; done;; esac }} # pick any app registered for the file's type (gio mime) in aurora's runner cmd open-with ${{ set -f app=$(gio mime "$(file -Lb --mime-type -- "$f")" | sed -n 's/^\t\(.*\)\.desktop$/\1/p' | sort -u | aurora-run -d -p "open with:") || exit 0 setsid -f gtk-launch "$app" $fx >/dev/null 2>&1 }} cmd mkdir %mkdir -p -- "$*" cmd touch %touch -- "$*" cmd extract ${{ clear; tput cup $(($(tput lines)/3)); tput bold set -f printf "%s\n\t" "$fx" printf "extract?[y/N]" read -r ans [ "$ans" = "y" ] && ext $fx }} # D / : gone for good, after a y/N prompt (no trash: /tmp etc. have none) cmd delete ${{ clear; tput cup $(($(tput lines)/3)); tput bold set -f printf "%s\n\t" "$fx" printf "delete permanently?[y/N]" read -r ans [ "$ans" = "y" ] && rm -rf -- $fx }} # M / C: move / copy the selection to a directory from ~/.config/lf/mvdirs cmd transfer ${{ set -f dest=$(sed "s|^\\\$HOME|$HOME|; s|^~|$HOME|" ~/.config/lf/mvdirs | fzf --prompt "$1 to: ") || exit 0 if [ "$1" = move ]; then mv -iv -- $fx "$dest"; else cp -ivr -- $fx "$dest"; fi notify-send "lf" "$1: $(printf '%s\n' "$fx" | wc -l) item(s) to $dest" }} cmd fzf-jump ${{ res=$(fd --hidden --exclude .git | fzf --prompt "jump: ") || exit 0 lf -remote "send $id select \"$(printf '%s' "$res" | sed 's/[\\"]/\\&/g')\"" }} # copy paths / names / the image itself cmd yank-path %printf '%s' "$fx" | wl-copy && lf -remote "send $id echo copied path" cmd yank-name %basename -a -- $fx | head -c -1 | wl-copy && lf -remote "send $id echo copied name" cmd yank-dir %printf '%s' "$PWD" | wl-copy && lf -remote "send $id echo copied $PWD" cmd yank-file %wl-copy --type "$(file -Lb --mime-type -- "$f")" < "$f" && lf -remote "send $id echo copied file contents" cmd setwall %setwall -p "$f" # window title = the directory (Hyprland, aurora's overview) cmd on-cd &{{ lf -remote "send $id tty-write \"\033]2;lf $(pwd | sed "s|^$HOME|~|")\007\"" }} on-cd # Bindings map fzf-jump map D delete map delete map p paste map dd cut map M transfer move map C transfer copy map yy copy map H top map E extract map push :mkdir map push :touch map reload map set hidden! map shell map x $$f map X !$f map o &xdg-open "$f" map O open-with map A :rename; cmd-end # at the very end map c push A # new rename map I :rename; cmd-home # at the very beginning map i :rename # before extension map a :rename; cmd-right # after extension map br $vimv map bg setwall map down map up map V push :!nvim map W $setsid -f $TERMINAL >/dev/null 2>&1 map Y yank-path map yp yank-path map yn yank-name map yd yank-dir map yi yank-file map T &~/.config/lf/remage-pick -t . # thumbnail grid of this directory, marks -> selection map unselect # movement map gd cd ~/dox/ map gD cd ~/dl/ map gp cd ~/pix map gw cd ~/pix/wallpapers map gc cd ~/.config map gC cd ~/.cache map gr cd ~/code/repos map gv cd ~/vids/ map gm cd ~/media/movies map gM cd ~/media map gn cd ~/music map gb cd ~/.local/bin map gt cd /tmp map gT cd ~/.local/share/Trash/files map gs cd ~/.local/share