| 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 period 1 |
| 9 | set hiddenfiles ".*:*.aux:*.log:*.bbl:*.bcf:*.blg:*.run.xml" |
| 10 | set cleaner '~/.config/lf/cleaner' |
| 11 | set previewer '~/.config/lf/scope' |
| 12 | |
| 13 | # cmds/functions |
| 14 | cmd open ${{ |
| 15 | case $(file --mime-type "$(readlink -f $f)" -b) in |
| 16 | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) localc $fx ;; |
| 17 | image/vnd.djvu|application/pdf|application/octet-stream|application/postscript) setsid -f zathura $fx >/dev/null 2>&1 ;; |
| 18 | text/*|application/json|inode/x-empty) $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\|tif\|ico\)\(_large\)*$" | |
| 22 | setsid -f sxiv -aio 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/*) mpv --audio-display=no $f ;; |
| 29 | video/*) setsid -f mpv $f -quiet >/dev/null 2>&1 ;; |
| 30 | application/pdf|application/vnd*|application/epub*) setsid -f zathura $fx >/dev/null 2>&1 ;; |
| 31 | application/pgp-encrypted) $EDITOR $fx ;; |
| 32 | *) for f in $fx; do setsid -f $OPENER $f >/dev/null 2>&1; done;; |
| 33 | esac |
| 34 | }} |
| 35 | |
| 36 | cmd mkdir $mkdir -p "$(echo $* | tr ' ' '\ ')" |
| 37 | |
| 38 | cmd extract ${{ |
| 39 | clear; tput cup $(($(tput lines)/3)); tput bold |
| 40 | set -f |
| 41 | printf "%s\n\t" "$fx" |
| 42 | printf "extract?[y/N]" |
| 43 | read ans |
| 44 | [ $ans = "y" ] && aunpack $fx |
| 45 | }} |
| 46 | |
| 47 | cmd delete ${{ |
| 48 | clear; tput cup $(($(tput lines)/3)); tput bold |
| 49 | set -f |
| 50 | printf "%s\n\t" "$fx" |
| 51 | printf "delete?[y/N]" |
| 52 | read ans |
| 53 | [ $ans = "y" ] && rm -rf -- $fx |
| 54 | }} |
| 55 | |
| 56 | cmd moveto ${{ |
| 57 | clear; tput cup $(($(tput lines)/3)); tput bold |
| 58 | set -f |
| 59 | clear; echo "Move to where?" |
| 60 | dest="$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf | sed 's|~|$HOME|')" && |
| 61 | for x in $fx; do |
| 62 | eval mv -iv \"$x\" \"$dest\" |
| 63 | done && |
| 64 | notify-send "🚚 File(s) moved." "File(s) moved to $dest." |
| 65 | }} |
| 66 | |
| 67 | cmd copyto ${{ |
| 68 | clear; tput cup $(($(tput lines)/3)); tput bold |
| 69 | set -f |
| 70 | clear; echo "Copy to where?" |
| 71 | dest="$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf | sed 's|~|$HOME|')" && |
| 72 | for x in $fx; do |
| 73 | eval cp -ivr \"$x\" \"$dest\" |
| 74 | done && |
| 75 | notify-send "📋 File(s) copied." "File(s) copies to $dest." |
| 76 | }} |
| 77 | |
| 78 | cmd setbg "$1" |
| 79 | cmd bulkrename $vidir |
| 80 | |
| 81 | # Bindings |
| 82 | map <c-f> $lf -remote "send $id select \"$(fzf)\"" |
| 83 | 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)" |
| 84 | map gh |
| 85 | map g top |
| 86 | map D delete |
| 87 | map E extract |
| 88 | map C copyto |
| 89 | map M moveto |
| 90 | map <c-n> push :mkdir<space> |
| 91 | map <c-r> reload |
| 92 | map <c-s> set hidden! |
| 93 | map <enter> shell |
| 94 | map x $$f |
| 95 | map X !$f |
| 96 | map o &mimeopen $f |
| 97 | map O $mimeopen --ask $f |
| 98 | |
| 99 | map A rename # at the very end |
| 100 | map c push A<c-u> # new rename |
| 101 | map I push A<c-a> # at the very beginning |
| 102 | map i push A<a-b><a-b><a-f> # before extension |
| 103 | map a push A<a-b> # after extension |
| 104 | map B bulkrename |
| 105 | map b $setbg $f |
| 106 | |
| 107 | map <c-e> down |
| 108 | map <c-y> up |
| 109 | map V push :!nvim<space> |
| 110 | |
| 111 | map W $setsid -f $TERMINAL >/dev/null 2>&1 |
| 112 | |
| 113 | map Y $printf "%s" "$fx" | xclip -selection clipboard |
| 114 | |
| 115 | # Source Bookmarks |
| 116 | #source "~/.config/lf/shortcutrc" |