moving tools from another repo
This commit is contained in:
58
shell/tsp-menu
Executable file
58
shell/tsp-menu
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ "$1" = "-h" ]]; then
|
||||
echo "utility to control tsp with menu"
|
||||
exit
|
||||
fi
|
||||
|
||||
. qolop
|
||||
_qCol export _
|
||||
function fkey_colorize() {
|
||||
for word in $@; do
|
||||
echo -ne "${_G}${word:0:1}${_Z}${word:1} "
|
||||
done
|
||||
echo
|
||||
}
|
||||
|
||||
function get_id() {
|
||||
tsp -l
|
||||
echo -e "${_Y}"
|
||||
read -i "$id" -e -p "id? " id
|
||||
echo -e "${_Z}"
|
||||
if [[ "$id" = q ]]; then
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
function shuffle_jobs() {
|
||||
ids=( $( tsp -l | tail -n +2 | grep queued | cut -d' ' -f1 ) )
|
||||
ids_len=${#ids[@]}
|
||||
for src in ${ids[@]}; do
|
||||
new=${ids[$(( $RANDOM % $ids_len ))]}
|
||||
if [[ $new -eq $src ]]; then
|
||||
continue
|
||||
fi
|
||||
tsp -U "${src}-${new}"
|
||||
done
|
||||
}
|
||||
|
||||
while true; do
|
||||
echo '$ 'tsp $cmd $id
|
||||
eval tsp $cmd $id
|
||||
id=""
|
||||
cmd=""
|
||||
echo
|
||||
fkey_colorize list console info remove kill Clear Slots shuffle Killall quit
|
||||
read -p"tsp " -n1 menu
|
||||
echo
|
||||
case "$menu" in
|
||||
q) break;;
|
||||
l) cmd=-l;;
|
||||
c|i|r|k) cmd=-"$menu"; get_id; ;;
|
||||
C) id=""; cmd=-C; ;;
|
||||
S) cmd=""; echo Current:; tsp -S; read -p "new? " -i 1 -e num; tsp -S $num; ;;
|
||||
K) read -p "sure? ctrl-c " foo; id=""; cmd=-K; ;;
|
||||
s) shuffle_jobs; ;;
|
||||
*) break;;
|
||||
esac
|
||||
done
|
||||
Reference in New Issue
Block a user