/
lfrc
91 lines (75 loc) 路 1.7 KB
/
lfrc
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
81
82
83
84
85
86
87
88
89
90
91
#
# Settings
#
set color256
# Would be nice to have equivalent of ranger's "set draw_borders separators"
# (drawbox is too much).
# set drawbox
set incsearch
set nodirfirst
set previewer ~/.config/lf/pv.sh
# Two columns.
set ratios 3:4
#
# Mappings
#
# Muscle memory (from vim-vinegar): - = updir
map - updir
# TODO: consider making this a template so that we can make it platform-specific
# and override easily
map gc cd ~/code
map gf $test -d $f && $OPENER $f || $OPENER -R $f
map gd cd ~/Downloads
map gp cd ~/Pictures
map gr cd /
map gT broot
map gt skim
# Muscle memory (from mutt): u = [u]pdir
map u updir
map <enter> open
# Muscle memory (from vim): move [i]nto of jump list.
#
# Terminal normally can't distinguish <C-I> from <Tab>; here, user
# presses <C-I>, Karabiner sends <F6>.
#
# Not supported yet, but hoping it will be...
#map <f-6> history-in
#
# Muscle memory (from vim): move [o]ut of jump list.
#
# Requires `stty discard undef` otherwise lf won't see C-O
#map <c-o> history-out
#
# Commands
#
# Based on `broot --print-shell-function bash`
cmd broot ${{
outcmd=$(mktemp)
(
set +e
# TODO: consider templating this for more control
broot -f -h --conf ~/.config/lf/broot.toml --outcmd "$outcmd"
code=$?
if [ "$code" != 0 ]; then
rm -f "$outcmd"
exit "$code"
fi
)
code=$?
if [ "$code" != 0 ]; then
return "$code"
fi
result=$(cat "$outcmd" | sed 's/^cd //')
rm -f "$outcmd"
lf -remote "send $id cd \"$result\""
}}
cmd open ${{
case $(file --brief --mime-type $f) in
text/*) $EDITOR $fx;;
*) for f in $fx; do open $f & done;;
esac
}}
cmd skim ${{
DIR=$(bfs -type d 2> /dev/null | sk --no-multi)
lf -remote "send $id cd \"$DIR\""
}}