summaryrefslogtreecommitdiff
path: root/.local/bin/osel
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/osel')
-rwxr-xr-x.local/bin/osel43
1 files changed, 36 insertions, 7 deletions
diff --git a/.local/bin/osel b/.local/bin/osel
index 3d9e543..e576a7b 100755
--- a/.local/bin/osel
+++ b/.local/bin/osel
@@ -1,11 +1,40 @@
#!/bin/sh
-x="`
-if [ -t 2 ]
-then
- eval fzf $OSEL_TERM_FLAGS
-else
- eval fuzzel -d $OSEL_GUI_FLAGS
-fi`"
+index()
+{
+ if [ -t 2 ]
+ then
+ nl -nln -v0 \
+ | eval fzf --with-nth=2 $OSEL_TERM_FLAGS \
+ | cut -f1 -d' '
+ else
+ eval fuzzel -d --index $OSEL_GUI_FLAGS
+ fi
+}
+
+normal()
+{
+ if [ -t 2 ]
+ then
+ eval fzf $OSEL_TERM_FLAGS
+ else
+ eval fuzzel -d $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"