even more stuff to tsp-menu
This commit is contained in:
@@ -14,6 +14,10 @@ function fkey_colorize() {
|
|||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _title() {
|
||||||
|
echo -e "${_U}${_S}======= $@ =======${_Z}"
|
||||||
|
}
|
||||||
|
|
||||||
function get_id() {
|
function get_id() {
|
||||||
tsp -l
|
tsp -l
|
||||||
echo -e "${_Y}"
|
echo -e "${_Y}"
|
||||||
@@ -36,23 +40,85 @@ function shuffle_jobs() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _del_logs() {
|
||||||
|
shopt -s nullglob
|
||||||
|
if [[ -z $( ls -1 /tmp/ | grep ^ts-out\. ) ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
ls -1 -l /tmp/ts-out.*
|
||||||
|
read -p"sure to delete logs? y/n " -n1 deletelogs
|
||||||
|
echo
|
||||||
|
if [[ "$deletelogs" = y ]]; then
|
||||||
|
find /tmp -mindepth 1 -maxdepth 1 -name 'ts-out.*' -delete -print
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function _kill_all() {
|
||||||
|
tsp -l
|
||||||
|
read -p"sure to kill all jobs (and daemon)? y/n " -n1 killtsp
|
||||||
|
echo
|
||||||
|
if [[ "$killtsp" = y ]]; then
|
||||||
|
tsp -K
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function _status() {
|
||||||
|
_title Status
|
||||||
|
echo -n "Parallel jobs (-S): "
|
||||||
|
tsp -S
|
||||||
|
echo -n "Running jobs: "
|
||||||
|
tsp -l | tail -n +2 | awk '{print $2}' | grep -c running
|
||||||
|
echo -n "Queued jobs: "
|
||||||
|
tsp -l | tail -n +2 | awk '{print $2}' | grep -c queued
|
||||||
|
echo -n "Finished jobs in success: "
|
||||||
|
tsp -l | tail -n +2 | awk '{print $2 $4}' | grep -c finished0
|
||||||
|
echo -n "Finished jobs with error: "
|
||||||
|
tsp -l | tail -n +2 | awk '{print $2 $4}' | grep finished | grep -v -c finished0
|
||||||
|
read -p "OK " foo
|
||||||
|
}
|
||||||
|
function _create_tsp_jobs() {
|
||||||
|
for i in {1..5}; do
|
||||||
|
tsp sleep 0.1
|
||||||
|
done
|
||||||
|
for i in {1..5}; do
|
||||||
|
tsp sleep 10
|
||||||
|
done
|
||||||
|
for i in {1..5}; do
|
||||||
|
tsp sleep 180
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
|
_title "TSP"
|
||||||
echo '$ 'tsp $cmd $id
|
echo '$ 'tsp $cmd $id
|
||||||
eval tsp $cmd $id
|
if [[ "$cmd" = "-c" ]]; then
|
||||||
|
eval tsp $cmd $id | less -R +G
|
||||||
|
else
|
||||||
|
eval tsp $cmd $id
|
||||||
|
fi
|
||||||
id=""
|
id=""
|
||||||
cmd=""
|
cmd=""
|
||||||
echo
|
echo
|
||||||
fkey_colorize list console info remove kill Clear Slots shuffle Killall quit
|
fkey_colorize list console info remove kill Clear Slots shuffle DelLogs Killall @status quit
|
||||||
read -p"tsp " -n1 menu
|
read -p"tsp " -n1 menu
|
||||||
|
if [[ "$menu" = "" ]]; then
|
||||||
|
read -t 0.1 -n1 special
|
||||||
|
if [[ -n "$special" ]]; then menu=l; fi
|
||||||
|
fi
|
||||||
echo
|
echo
|
||||||
case "$menu" in
|
case "$menu" in
|
||||||
q) break;;
|
q|) break;;
|
||||||
l) cmd=-l;;
|
l) cmd=-l;;
|
||||||
c|i|r|k) cmd=-"$menu"; get_id; ;;
|
c|i|r|k) cmd=-"$menu"; _title "Which ID?"; get_id; ;;
|
||||||
C) id=""; cmd=-C; ;;
|
C) cmd=-C; ;;
|
||||||
S) cmd=""; echo Current:; tsp -S; read -p "new? " -i 1 -e num; tsp -S $num; ;;
|
S) cmd=""; _title Current:; tsp -S; read -p "new? " -i 1 -e num; tsp -S $num; ;;
|
||||||
K) read -p "sure? ctrl-c " foo; id=""; cmd=-K; ;;
|
K) _kill_all ;;
|
||||||
s) shuffle_jobs; ;;
|
D) _del_logs ;;
|
||||||
*) break;;
|
s) shuffle_jobs ;;
|
||||||
|
@) _status ;;
|
||||||
|
*) cmd=-l;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user