Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- (( $# )) && echo arguments are ignored
- echo 'Useage: variety -<input>
- --* -> read more then 1 char
- -q -> --quit (Also quits from ^D)
- -n -> --next
- -p -> --previous
- -t -> --trash
- -f -> --favorite
- '
- # trap KILL? 'variety -q' ?todo?
- { pidof variety || variety --pause; } &>/dev/null & # in case if is not running
- eof=$'\4' # end of input ( Ctrl+D = ^D )
- er(){ printf "\\E[10Cvariety err code: $?\\E[28D\\E[${#?}D"; }
- while IFS= read -p 'variety -' -n 1 i; do case $i in
- [nptf]) { variety -"$i" &>/dev/null || er; } &;;
- -|["\'\""]) read j || break; eval "variety -$i$j || er";;
- q|"$eof") break;;
- [$'\E\t ']|'') read -t 0.1 -s -p $'\r \r' _; continue;; # ignore arow + special keys
- *) printf '\n invalid option: %s' "${i@Q}";;
- esac; echo; done
- echo
- variety --quit &>/dev/null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement