Krolyxon
Commit e70f5a5

Branches

Refs →

aurora.configlflfrc

167 lines · 5.5 KB

1# Basic vars
2set shellopts '-eu'
3set ifs "\n"
4set scrolloff 10
5set icons
6set hidden true
7set drawbox true
8set roundbox true
9set watch true # files other programs add or remove (remage, downloads, waldl) show up without polling
10set previewer '~/.config/lf/scope'
11set preload true
12set autoquit true
13
14# cmds/functions
15cmd 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
40cmd 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
47cmd mkdir %mkdir -p -- "$*"
48cmd touch %touch -- "$*"
49
50cmd 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
60cmd 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
66cmd 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
72cmd 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
82cmd 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
89cmd 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
95cmd yank-path %printf '%s' "$fx" | wl-copy && lf -remote "send $id echo copied path"
96cmd yank-name %basename -a -- $fx | head -c -1 | wl-copy && lf -remote "send $id echo copied name"
97cmd yank-dir %printf '%s' "$PWD" | wl-copy && lf -remote "send $id echo copied $PWD"
98cmd yank-file %wl-copy --type "$(file -Lb --mime-type -- "$f")" < "$f" && lf -remote "send $id echo copied file contents"
99
100cmd setwall %setwall -p "$f"
101
102# window title = the directory (Hyprland, aurora's overview)
103cmd on-cd &{{
104 lf -remote "send $id tty-write \"\033]2;lf $(pwd | sed "s|^$HOME|~|")\007\""
105}}
106on-cd
107
108# Bindings
109map <c-f> fzf-jump
110map D trash
111map <delete> delete
112map U restore
113map p paste
114map dd cut
115map M transfer move
116map C transfer copy
117map yy copy
118map H top
119map E extract
120map <c-n> push :mkdir<space>
121map <c-t> push :touch<space>
122map <c-r> reload
123map <c-s> set hidden!
124map <enter> shell
125map x $$f
126map X !$f
127map o &xdg-open "$f"
128map O open-with
129
130map A :rename; cmd-end # at the very end
131map c push A<c-u> # new rename
132map I :rename; cmd-home # at the very beginning
133map i :rename # before extension
134map a :rename; cmd-right # after extension
135map br $vimv
136map bg setwall
137
138map <c-e> down
139map <c-y> up
140map V push :!nvim<space>
141
142map W $setsid -f $TERMINAL >/dev/null 2>&1
143
144map Y yank-path
145map yp yank-path
146map yn yank-name
147map yd yank-dir
148map yi yank-file
149map T &~/.config/lf/remage-pick -t . # thumbnail grid of this directory, marks -> selection
150map <c-l> unselect
151
152# movement
153map gd cd ~/dox/
154map gD cd ~/dl/
155map gp cd ~/pix
156map gw cd ~/pix/wallpapers
157map gc cd ~/.config
158map gC cd ~/.cache
159map gr cd ~/code/repos
160map gv cd ~/vids/
161map gm cd ~/media/movies
162map gM cd ~/media
163map gn cd ~/music
164map gb cd ~/.local/bin
165map gt cd /tmp
166map gT cd ~/.local/share/Trash/files
167map gs cd ~/.local/share