| 1 | # Basic vars |
| 2 | set shellopts '-eu' |
| 3 | set ifs "\n" |
| 4 | set scrolloff 10 |
| 5 | set icons |
| 6 | set hidden true |
| 7 | set drawbox true |
| 8 | set roundbox true |
| 9 | set watch true # files other programs add or remove (remage, downloads, waldl) show up without polling |
| 10 | set previewer '~/.config/lf/scope' |
| 11 | set preload true |
| 12 | set autoquit true |
| 13 | |
| 14 | # cmds/functions |
| 15 | cmd open ${{ |
| 16 | set -f |
| 17 | case $(file --mime-type "$(readlink -f "$f")" -b) in |
| 18 | image/vnd.djvu|application/pdf|application/postscript) setsid -f zathura $fx >/dev/null 2>&1 ;; |
| 19 | text/*|application/json|inode/x-empty|application/x-subrip) $EDITOR $fx;; |
| 20 | image/x-xcf) setsid -f gimp "$f" >/dev/null 2>&1 ;; |
| 21 | # one image = remage on its whole directory, starting there; a selection = just those. |
| 22 | # Images marked in remage (m) become the selection here. |
| 23 | image/*) setsid -f ~/.config/lf/remage-pick $fx >/dev/null 2>&1 ;; |
| 24 | audio/*|video/x-ms-asf) mpv --audio-display=no $fx ;; |
| 25 | video/*) setsid -f mpv $fx -quiet >/dev/null 2>&1 ;; |
| 26 | application/vnd.djvu|application/epub*) setsid -f zathura $fx >/dev/null 2>&1 ;; |
| 27 | application/pgp-encrypted) $EDITOR $fx ;; |
| 28 | 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 ;; |
| 29 | application/octet-stream) case ${f##*.} in |
| 30 | doc|docx|xls|xlsx|odt|ppt|pptx) setsid -f libreoffice $fx >/dev/null 2>&1 ;; |
| 31 | ghw) setsid -f gtkwave "$f" >/dev/null 2>&1 ;; |
| 32 | ts) setsid -f mpv $fx -quiet >/dev/null 2>&1 ;; |
| 33 | *) setsid -f zathura $fx >/dev/null 2>&1 ;; |
| 34 | esac ;; |
| 35 | *) for f in $fx; do setsid -f xdg-open "$f" >/dev/null 2>&1; done;; |
| 36 | esac |
| 37 | }} |
| 38 | |
| 39 | # pick any app registered for the file's type (gio mime) in aurora's runner |
| 40 | cmd open-with ${{ |
| 41 | set -f |
| 42 | app=$(gio mime "$(file -Lb --mime-type -- "$f")" | sed -n 's/^\t\(.*\)\.desktop$/\1/p' | sort -u | |
| 43 | aurora-run -d -p "open with:") || exit 0 |
| 44 | setsid -f gtk-launch "$app" $fx >/dev/null 2>&1 |
| 45 | }} |
| 46 | |
| 47 | cmd mkdir %mkdir -p -- "$*" |
| 48 | cmd touch %touch -- "$*" |
| 49 | |
| 50 | cmd extract ${{ |
| 51 | clear; tput cup $(($(tput lines)/3)); tput bold |
| 52 | set -f |
| 53 | printf "%s\n\t" "$fx" |
| 54 | printf "extract?[y/N]" |
| 55 | read -r ans |
| 56 | [ "$ans" = "y" ] && ext $fx |
| 57 | }} |
| 58 | |
| 59 | # D: to the trash (gio, restorable with U); <delete>: gone for good |
| 60 | cmd trash %{{ |
| 61 | set -f |
| 62 | gio trash -- $fx |
| 63 | lf -remote "send $id :unselect; echo trashed $(printf '%s\n' "$fx" | wc -l) item(s), U restores" |
| 64 | }} |
| 65 | |
| 66 | cmd restore ${{ |
| 67 | pick=$(gio trash --list | awk -F '\t' '{ print $2 "\t" $1 }' | |
| 68 | fzf --multi --delimiter '\t' --with-nth 1 --prompt "restore: ") || exit 0 |
| 69 | printf '%s\n' "$pick" | cut -f2 | while read -r uri; do gio trash --restore "$uri"; done |
| 70 | }} |
| 71 | |
| 72 | cmd delete ${{ |
| 73 | clear; tput cup $(($(tput lines)/3)); tput bold |
| 74 | set -f |
| 75 | printf "%s\n\t" "$fx" |
| 76 | printf "delete permanently?[y/N]" |
| 77 | read -r ans |
| 78 | [ "$ans" = "y" ] && rm -rf -- $fx |
| 79 | }} |
| 80 | |
| 81 | # M / C: move / copy the selection to a directory from ~/.config/lf/mvdirs |
| 82 | cmd transfer ${{ |
| 83 | set -f |
| 84 | dest=$(sed "s|^\\\$HOME|$HOME|; s|^~|$HOME|" ~/.config/lf/mvdirs | fzf --prompt "$1 to: ") || exit 0 |
| 85 | if [ "$1" = move ]; then mv -iv -- $fx "$dest"; else cp -ivr -- $fx "$dest"; fi |
| 86 | notify-send "lf" "$1: $(printf '%s\n' "$fx" | wc -l) item(s) to $dest" |
| 87 | }} |
| 88 | |
| 89 | cmd fzf-jump ${{ |
| 90 | res=$(fd --hidden --exclude .git | fzf --prompt "jump: ") || exit 0 |
| 91 | lf -remote "send $id select \"$(printf '%s' "$res" | sed 's/[\\"]/\\&/g')\"" |
| 92 | }} |
| 93 | |
| 94 | # copy paths / names / the image itself |
| 95 | cmd yank-path %printf '%s' "$fx" | wl-copy && lf -remote "send $id echo copied path" |
| 96 | cmd yank-name %basename -a -- $fx | head -c -1 | wl-copy && lf -remote "send $id echo copied name" |
| 97 | cmd yank-dir %printf '%s' "$PWD" | wl-copy && lf -remote "send $id echo copied $PWD" |
| 98 | cmd yank-file %wl-copy --type "$(file -Lb --mime-type -- "$f")" < "$f" && lf -remote "send $id echo copied file contents" |
| 99 | |
| 100 | cmd setwall %setwall -p "$f" |
| 101 | |
| 102 | # window title = the directory (Hyprland, aurora's overview) |
| 103 | cmd on-cd &{{ |
| 104 | lf -remote "send $id tty-write \"\033]2;lf $(pwd | sed "s|^$HOME|~|")\007\"" |
| 105 | }} |
| 106 | on-cd |
| 107 | |
| 108 | # Bindings |
| 109 | map <c-f> fzf-jump |
| 110 | map D trash |
| 111 | map <delete> delete |
| 112 | map U restore |
| 113 | map p paste |
| 114 | map dd cut |
| 115 | map M transfer move |
| 116 | map C transfer copy |
| 117 | map yy copy |
| 118 | map H top |
| 119 | map E extract |
| 120 | map <c-n> push :mkdir<space> |
| 121 | map <c-t> push :touch<space> |
| 122 | map <c-r> reload |
| 123 | map <c-s> set hidden! |
| 124 | map <enter> shell |
| 125 | map x $$f |
| 126 | map X !$f |
| 127 | map o &xdg-open "$f" |
| 128 | map O open-with |
| 129 | |
| 130 | map A :rename; cmd-end # at the very end |
| 131 | map c push A<c-u> # new rename |
| 132 | map I :rename; cmd-home # at the very beginning |
| 133 | map i :rename # before extension |
| 134 | map a :rename; cmd-right # after extension |
| 135 | map br $vimv |
| 136 | map bg setwall |
| 137 | |
| 138 | map <c-e> down |
| 139 | map <c-y> up |
| 140 | map V push :!nvim<space> |
| 141 | |
| 142 | map W $setsid -f $TERMINAL >/dev/null 2>&1 |
| 143 | |
| 144 | map Y yank-path |
| 145 | map yp yank-path |
| 146 | map yn yank-name |
| 147 | map yd yank-dir |
| 148 | map yi yank-file |
| 149 | map T &~/.config/lf/remage-pick -t . # thumbnail grid of this directory, marks -> selection |
| 150 | map <c-l> unselect |
| 151 | |
| 152 | # movement |
| 153 | map gd cd ~/dox/ |
| 154 | map gD cd ~/dl/ |
| 155 | map gp cd ~/pix |
| 156 | map gw cd ~/pix/wallpapers |
| 157 | map gc cd ~/.config |
| 158 | map gC cd ~/.cache |
| 159 | map gr cd ~/code/repos |
| 160 | map gv cd ~/vids/ |
| 161 | map gm cd ~/media/movies |
| 162 | map gM cd ~/media |
| 163 | map gn cd ~/music |
| 164 | map gb cd ~/.local/bin |
| 165 | map gt cd /tmp |
| 166 | map gT cd ~/.local/share/Trash/files |
| 167 | map gs cd ~/.local/share |