blob: 30a5424606a3805a92f0b46bedb903ea9fc07682 (
plain)
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
|
#!/bin/sh
# Search and open man page
# Options:
# -t use in terminal with fzf otherwise launch bemenu.
# -s search with apropos.
# Source settings from .bemenurc
. ~/.config/bemenurc
issearch=
isterminal=
printusage() {
echo "Options:" >2
echo " -t use in terminal with fzf otherwise launch bemenu." >2
echo " -s search with apropos." >2
}
while getopts "st" curopt "$@"; do
case "$curopt" in
"s")
issearch=1
continue;;
"t")
isterminal=1
continue;;
"?")
printusage
exit 1;;
esac
done
if [ ! -z "$issearch" ]; then
if [ ! -z "$isterminal" ]; then
printf "Enter query:\t"
read query
else
query="$(echo "" | bemenu -p "Enter apropos query:" -i --tf="$BEMENU_TF" --tb="$BEMENU_NB" --fb="$BEMENU_NB" --fn="$BEMENU_FN" --nb="$BEMENU_NB" --nf="$BEMENU_NF" --hf="$BEMENU_HF" --hb="$BEMENU_HB" --monitor="$BEMENU_MONITOR")"
fi
if [ -z "$query" ]; then
echo "Empty query" >2
exit 1
fi
list="$(apropos "$query")"
else
list="$(man -k . | awk '{ print $1$2 }')"
fi
if [ ! -z "$isterminal" ]; then
chosen=$(printf "$list" | fzf)
else
chosen=$(printf "$list" | bemenu -p "Select man page:" -i -l 25 --tf="$BEMENU_TF" --tb="$BEMENU_NB" --fb="$BEMENU_NB" --fn="$BEMENU_FN" --nb="$BEMENU_NB" --nf="$BEMENU_NF" --hf="$BEMENU_HF" --hb="$BEMENU_HB" --monitor="$BEMENU_MONITOR")
fi
if [ -z "$chosen" ]; then
exit 0
fi
if [ ! -z "$issearch" ]; then
chosen="$(printf "$chosen" | sed "s/\(.* ([a-zA-Z0-9]*)\)\s*-.*/\1/")"
fi
if [ ! -z "$isterminal" ]; then
man "$chosen" && exit
fi
$TERMINAL -T "man $chosen" man $chosen
|