| @@ -1,94 +1,131 @@ |
| 1 | 1 | | # Basic vars |
| 2 | | − | # set sixel true |
| 3 | 2 | | set shellopts '-eu' |
| 4 | 3 | | set ifs "\n" |
| 5 | 4 | | set scrolloff 10 |
| 6 | 5 | | set icons |
| 7 | 6 | | set hidden true |
| 8 | 7 | | set drawbox true |
| 9 | | − | set period 1 |
| 8 | + | set roundbox true |
| 9 | + | set watch true # files other programs add or remove (remage, downloads, waldl) show up without polling |
| 10 | 10 | | set previewer '~/.config/lf/scope' |
| 11 | + | set preload true |
| 11 | 12 | | set autoquit true |
| 12 | 13 | | |
| 13 | 14 | | # cmds/functions |
| 14 | 15 | | cmd open ${{ |
| 15 | | − | case $(file --mime-type "$(readlink -f $f)" -b) in |
| 16 | | − | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) localc $fx ;; |
| 16 | + | set -f |
| 17 | + | case $(file --mime-type "$(readlink -f "$f")" -b) in |
| 17 | 18 | | image/vnd.djvu|application/pdf|application/postscript) setsid -f zathura $fx >/dev/null 2>&1 ;; |
| 18 | 19 | | text/*|application/json|inode/x-empty|application/x-subrip) $EDITOR $fx;; |
| 19 | | − | image/x-xcf) setsid -f gimp $f >/dev/null 2>&1 ;; |
| 20 | | − | image/svg+xml) display -- $f ;; |
| 21 | | − | image/*) rotdir $f | grep -i "\.\(png\|jpg\|jpeg\|gif\|webp\|avif\|tif\|ico\|heic\)\(_large\)*$" | |
| 22 | | − | setsid -f remage -io 2>/dev/null | while read -r file; do |
| 23 | | − | [ -z "$file" ] && continue |
| 24 | | − | lf -remote "send select \"$file\"" |
| 25 | | − | lf -remote "send toggle" |
| 26 | | − | done & |
| 27 | | − | ;; |
| 28 | | − | audio/*|video/x-ms-asf) mpv --audio-display=no $f ;; |
| 29 | | − | video/*) setsid -f mpv $f -quiet >/dev/null 2>&1 ;; |
| 30 | | − | application/pdf|application/vnd.djvu|application/epub*) setsid -f zathura $fx >/dev/null 2>&1 ;; |
| 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 ;; |
| 31 | 27 | | application/pgp-encrypted) $EDITOR $fx ;; |
| 32 | 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 ;; |
| 33 | 29 | | application/octet-stream) case ${f##*.} in |
| 34 | 30 | | doc|docx|xls|xlsx|odt|ppt|pptx) setsid -f libreoffice $fx >/dev/null 2>&1 ;; |
| 35 | | − | ghw) setsid -f gtkwave $f >/dev/null 2>&1 ;; |
| 36 | | − | ts) setsid -f mpv $f -quiet >/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 ;; |
| 37 | 33 | | *) setsid -f zathura $fx >/dev/null 2>&1 ;; |
| 38 | 34 | | esac ;; |
| 39 | | − | *) for f in $fx; do setsid -f $OPENER $f >/dev/null 2>&1; done;; |
| 35 | + | *) for f in $fx; do setsid -f xdg-open "$f" >/dev/null 2>&1; done;; |
| 40 | 36 | | esac |
| 41 | 37 | | }} |
| 42 | | − | cmd mkdir $mkdir -p "$(echo $* | tr ' ' '\ ')" |
| 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 -- "$*" |
| 43 | 49 | | |
| 44 | 50 | | cmd extract ${{ |
| 45 | 51 | | clear; tput cup $(($(tput lines)/3)); tput bold |
| 46 | 52 | | set -f |
| 47 | 53 | | printf "%s\n\t" "$fx" |
| 48 | 54 | | printf "extract?[y/N]" |
| 49 | | − | read ans |
| 50 | | − | [ $ans = "y" ] && ext $fx |
| 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 |
| 51 | 70 | | }} |
| 52 | 71 | | |
| 53 | 72 | | cmd delete ${{ |
| 54 | 73 | | clear; tput cup $(($(tput lines)/3)); tput bold |
| 55 | 74 | | set -f |
| 56 | 75 | | printf "%s\n\t" "$fx" |
| 57 | | − | printf "delete?[y/N]" |
| 58 | | − | read ans |
| 59 | | − | [ $ans = "y" ] && rm -rf -- $fx |
| 76 | + | printf "delete permanently?[y/N]" |
| 77 | + | read -r ans |
| 78 | + | [ "$ans" = "y" ] && rm -rf -- $fx |
| 60 | 79 | | }} |
| 61 | 80 | | |
| 62 | | − | cmd moveto ${{ |
| 63 | | − | clear; tput cup $(($(tput lines)/3)); tput bold |
| 81 | + | # M / C: move / copy the selection to a directory from ~/.config/lf/mvdirs |
| 82 | + | cmd transfer ${{ |
| 64 | 83 | | set -f |
| 65 | | − | clear; echo "Move to where?" |
| 66 | | − | dest=$(cat ~/.config/lf/mvdirs | fzf ) |
| 67 | | − | for x in $fx; do |
| 68 | | − | eval mv -iv \"$x\" \"$dest\" |
| 69 | | − | done && |
| 70 | | − | notify-send "🚚 File(s) moved." "File(s) moved to $dest." |
| 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')\"" |
| 71 | 92 | | }} |
| 72 | 93 | | |
| 73 | | − | cmd setwall -p "$1" |
| 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 |
| 74 | 107 | | |
| 75 | 108 | | # Bindings |
| 76 | | − | map <c-f> $lf -remote "send $id select \"$(fzf)\"" |
| 77 | | − | map D delete |
| 109 | + | map <c-f> fzf-jump |
| 110 | + | map D trash |
| 111 | + | map <delete> delete |
| 112 | + | map U restore |
| 78 | 113 | | map p paste |
| 79 | 114 | | map dd cut |
| 80 | | − | map M moveto |
| 115 | + | map M transfer move |
| 116 | + | map C transfer copy |
| 81 | 117 | | map yy copy |
| 82 | 118 | | map H top |
| 83 | 119 | | map E extract |
| 84 | 120 | | map <c-n> push :mkdir<space> |
| 121 | + | map <c-t> push :touch<space> |
| 85 | 122 | | map <c-r> reload |
| 86 | 123 | | map <c-s> set hidden! |
| 87 | 124 | | map <enter> shell |
| 88 | 125 | | map x $$f |
| 89 | 126 | | map X !$f |
| 90 | | − | map o &mimeopen $f |
| 91 | | − | map O $mimeopen --ask $f |
| 127 | + | map o &xdg-open "$f" |
| 128 | + | map O open-with |
| 92 | 129 | | |
| 93 | 130 | | map A :rename; cmd-end # at the very end |
| 94 | 131 | | map c push A<c-u> # new rename |
| @@ -96,7 +133,7 @@ map I :rename; cmd-home # at the very beginning |
| 96 | 133 | | map i :rename # before extension |
| 97 | 134 | | map a :rename; cmd-right # after extension |
| 98 | 135 | | map br $vimv |
| 99 | | − | map bg $setwall -p $f |
| 136 | + | map bg setwall |
| 100 | 137 | | |
| 101 | 138 | | map <c-e> down |
| 102 | 139 | | map <c-y> up |
| @@ -104,14 +141,19 @@ map V push :!nvim<space> |
| 104 | 141 | | |
| 105 | 142 | | map W $setsid -f $TERMINAL >/dev/null 2>&1 |
| 106 | 143 | | |
| 107 | | − | map Y $printf "%s" "$fx" | xclip -selection clipboard |
| 108 | | − | map T $nsxiv -t "$(pwd)" # opens thumbnail mode |
| 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 |
| 109 | 150 | | map <c-l> unselect |
| 110 | 151 | | |
| 111 | 152 | | # movement |
| 112 | 153 | | map gd cd ~/dox/ |
| 113 | 154 | | map gD cd ~/dl/ |
| 114 | 155 | | map gp cd ~/pix |
| 156 | + | map gw cd ~/pix/wallpapers |
| 115 | 157 | | map gc cd ~/.config |
| 116 | 158 | | map gC cd ~/.cache |
| 117 | 159 | | map gr cd ~/code/repos |
| @@ -121,4 +163,5 @@ map gM cd ~/media |
| 121 | 163 | | map gn cd ~/music |
| 122 | 164 | | map gb cd ~/.local/bin |
| 123 | 165 | | map gt cd /tmp |
| 166 | + | map gT cd ~/.local/share/Trash/files |
| 124 | 167 | | map gs cd ~/.local/share |