diff options
author | Thomas Voss <mail@thomasvoss.com> | 2023-11-20 23:50:49 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2023-11-20 23:50:49 +0100 |
commit | 5f0c91f9675eec5854d68cacafad75efa71c65f5 (patch) | |
tree | 8425ad878c1d33a40150f23db2029026a5e4d20d /.local/bin/osel | |
parent | a3f1f4fbc3dbb1fcdd16a874e829f0cbd4c29870 (diff) |
osel: Add the ‘-i’ flag
Diffstat (limited to '.local/bin/osel')
-rwxr-xr-x | .local/bin/osel | 43 |
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" |