blob: ccabc967a98dc5bc612e22f771fa449da74458ee (
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
|
#!/bin/sh
OSEL_GUI_FLAGS="-d --log-level=warning $OSEL_GUI_FLAGS"
index()
{
if [ -t 2 ]
then
nl -nln -w1 -v0 \
| eval fzf --with-nth=2.. $OSEL_TERM_FLAGS \
| cut -f1
else
eval fuzzel --index $OSEL_GUI_FLAGS
fi
}
normal()
{
if [ -t 2 ]
then
eval fzf $OSEL_TERM_FLAGS
else
eval fuzzel $OSEL_GUI_FLAGS
fi
}
f=normal
while getopts 'i' opt
do
case $opt in
i)
f=index
;;
*)
echo "Usage: osel [-i]" >&2
exit 1
esac
done
x="$($f)"
[ -z "$x" ] && exit 1
printf '%s' "$x"
|