1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #!/bin/bash
- #eval $(xdotool getdisplaygeometry --shell)
- SCRIPT=`realpath $0`
- dir=`dirname $SCRIPT`
- src=${@:1:1}
- opt=${@:2:1}
- src=$(ls $dir/$src*.sh)
- if [ -z "$opt" ]; then
- opts=$(grep "==.*\$opt" $src | grep -v grep | sed 's/[^"]*"//;s/".*//')
- echo "Work Options: "$opts
- else
- #short hand
- c=$(echo "$opt" | sed 's/[0-9]//g')
- opts=$(grep "==.*\$opt" $src | grep -v grep | sed 's/[^"]*"//;s/".*//')
- list=$(echo "$opts" | grep ^$c)
- opts=($(echo $list))
- count=${#opts[@]}
-
- if [ "2" -gt "$count" ]; then
- echo "olv work ${opts[0]} ${@:2}"
- else
- index=$(echo $opt | sed 's/[^0-9]//g')
- if [ -z "$index" ]; then
- echo "Options:"
- echo "$list" | nl -v0
- read -p "olv work $c#: " index
-
- index=$(echo "$index" | sed 's/[^0-9]//g')
- if [ -z "$index" ]; then
- echo "No option selected."
- exit
- fi
- fi
-
- echo "olv work ${opts[$index]} ${@:2}"
- fi
- fi
|