-
-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathihelp.sh
executable file
·188 lines (170 loc) · 2.91 KB
/
ihelp.sh
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#!/bin/sh
# Interactive help plugin for Clifm
# Written by L. Abramovich
# License: GPL2+
# Dependencies: man, sed, less, and fzf or rofi
if [ -n "$1" ] && { [ "$1" = "--help" ] || [ "$1" = "-h" ]; }; then
name="${CLIFM_PLUGIN_NAME:-$(basename "$0")}"
printf "Interactively browse the Clifm manpage via FZF or Rofi\n"
printf "\n\x1b[1mUSAGE\x1b[0m\n %s\n" "$name"
exit 0
fi
if ! type man > /dev/null 2>&1; then
printf "clifm: man: Command not found\n" >&2
exit 127
fi
manpage="$(man -w clifm)"
if ! [ -f "$manpage" ]; then
printf "clifm: no manpage found\n" >&2
exit 1
fi
if type fzf >/dev/null 2>&1; then
filter="fzf"
elif type rofi >/dev/null 2>&1; then
filter="rofi"
else
printf "clifm: No finder found. Install either fzf or rofi\n" >&2
exit 1
fi
tmp=""
if [ -n "$MANPAGER" ]; then
tmp="$MANPAGER"
unset MANPAGER
fi
# Source our plugins helper
if [ -z "$CLIFM_PLUGINS_HELPER" ] || ! [ -f "$CLIFM_PLUGINS_HELPER" ]; then
printf "clifm: Unable to find the plugins-helper file\n" >&2
exit 1
fi
# shellcheck source=/dev/null
. "$CLIFM_PLUGINS_HELPER"
CMDS="1. GETTING HELP@
2. DESCRIPTION@
3. PARAMETERS@
POSITIONAL PARAMETERS@
OPTIONS@
4. COMMANDS@
5. FILE FILTERS@
6. KEYBOARD SHORTCUTS@
7. THEMING@
8. BUILT-IN EXPANSIONS@
9. RESOURCE OPENER@
10. SHOTGUN@
11. AUTO-SUGGESTIONS@
12. SHELL FUNCTIONS@
13. PLUGINS@
14. AUTOCOMMANDS@
15. FILE TAGS@
16. VIRTUAL DIRECTORIES@
17. NOTE ON SPEED
18. KANGAROO FRECENCY ALGORITHM@
19. ENVIRONMENT@
20. SECURITY@
21. MISCELLANEOUS NOTES@
22. FILES@
23. EXAMPLES@
FILE/DIR@
/PATTERN@
;\[CMD\], :\[CMD\]@
ac, ad@
acd, autocd@
actions @
alias @
ao, auto-open@
auto @
b, back@
bb, bleach@
bd @
bl @
bm, bookmarks@
br, bulk@
c, l@
colors@
cd @
cl, columns@
cmd, commands@
config @
cs, colorschemes@
d, dup@
ds, desel@
exp @
ext @
f, forth@
fc @
ff, dirs-first@
ft, filter@
fz @
hf, hh, hidden@
history @
icons @
j @
k@
kk@
kb, keybinds@
log @
ll, lv@
lm @
media@
mf @
mm, mime@
mp, mountpoints@
msg, messages@
n, new@
net \[@
o, open@
oc @
opener @
ow @
pc @
pin @
pf, profile@
pg, pager@
p, prop@
prompt@
q, quit, exit, Q@
rl, reload@
rf, refresh@
rr @
s, sel@
sb, selbox@
splash @
st, sort@
stats @
t, trash@
tag @
te @
tips @
u, undel, untrash@
unpin @
v, paste@
vv @
view@
ver, version@
ws@
x, X@"
a="-"
_colors="$(get_fzf_colors)"
# shellcheck disable=SC2046
while [ -n "$a" ]; do
if [ "$filter" = "fzf" ]; then
# shellcheck disable=SC2154
a="$(printf "%s\n" "$CMDS" | sed 's/@//g' | fzf --prompt="$fzf_prompt" --header "Browse Clifm's manpage" --reverse --height="$fzf_height" --info=inline --color="$_colors")"
else
a="$(printf "%s\n" "$CMDS" | sed 's/@//g' | rofi -dmenu -p "clifm")"
fi
if [ -n "$a" ]; then
if echo "$a" | grep -q '^[1-9,A-Z].*'; then
# shellcheck disable=SC2089
export PAGER="less -gp \"$a\""
else
# shellcheck disable=SC2090
export PAGER="less -gp \" $a\""
fi
man clifm
fi
done
printf "\n"
if [ -n "$tmp" ]; then
export MANPAGER="$tmp"
fi
exit 0