aboutsummaryrefslogtreecommitdiff
path: root/.config/lf/lfrc
blob: 86741e854bda935cd5f0594568a02eb9537045f3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
set promptfmt "\033[35;1m%u@%h\033[0m \033[36;1m%d\033[0m\033[1m%f\033[0m"
set cursorpreviewfmt "\033[7m"
set dircounts
set info size
set ratios 3:8:7
set scrolloff 3


map d
map dd cut
map dD delete

map s shell
map S $$SHELL

map a rename
map A :rename; cmd-end
map C bulkrename
map I :rename; cmd-home

map r push :open-with<space>
map <esc> redraw

map gh cd ~/
map gi $lf -remote "send $id cd /run/media/$USER"
map gm cd /mnt
map gs cd /smb

map bg &set-wallpaper "$fx"


cmd open ${{
	realfile="$(readlink -f -- "$fx")"
	if file -bi -- "$realfile" | grep -vq "charset=binary"; then
		$EDITOR -- "$fx"
	else
		mime="$(file -b --mime-type -- "$realfile")"
		case "$mime" in
			audio/*)
				if (type handlr 1>/dev/null 2>&1 && handlr get "$mime" 2>/dev/null | grep -qi "mpv") ||
					(type xdg-open 1>/dev/null 2>&1 && xdg-mime query default "$mime" 2>/dev/null | grep -qi "mpv"); then
					"$(command -v io.mpv.Mpv mpv | head -1)" -- "$fx"
				elif type handlr 1>/dev/null 2>&1; then
					setsid -f handlr open -- "$fx"
				elif type xdg-open 1>/dev/null 2>&1; then
					setsid -f xdg-open "$fx"
				fi;;
			image/*)
				if (type handlr 1>/dev/null 2>&1 && handlr get "$mime" 2>/dev/null | grep -qi "sxiv") ||
					(type xdg-open 1>/dev/null 2>&1 && xdg-mime query default "$mime" 2>/dev/null | grep -qi "sxiv"); then
					setsid -f sxiv-rifle "$f"
				elif type handlr 1>/dev/null 2>&1; then
					setsid -f handlr open -- "$fx"
				elif type xdg-open 1>/dev/null 2>&1; then
					setsid -f xdg-open "$fx"
				fi;;
			text/*)
				$EDITOR -- "$fx";;
			*)
				if type handlr 1>/dev/null 2>&1; then
					handlr open -- "$fx"
				elif type xdg-open 1>/dev/null 2>&1; then
					xdg-open "$fx"
				fi
		esac
	fi
}}

cmd open-with %setsid -f "$@" -- "$fx" 1>/dev/null 2>&1

cmd bulkrename ${{
	printf '%s\n' "$fx" | vidir -
}}

cmd on-cd &{{
	space_avail="$(df -h --output="avail" "$PWD" | awk 'FNR==2 {print $1}')"
	space_total="$(df -h --output="size"  "$PWD" | awk 'FNR==2 {print $1}')"
	printf "\033]0;(%s/%s) %s - LF\007" "$space_avail" "$space_total" "$PWD" 1>/dev/tty
}}
on-cd