added scripts that Ive been using for a while now
This commit is contained in:
27
.local/bin/tools/stopwatch
Executable file
27
.local/bin/tools/stopwatch
Executable file
@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
start_time_sec=$( date +'%s' )
|
||||
HOME=$(tput cup 0 0)
|
||||
ED=$(tput ed)
|
||||
EL=$(tput el)
|
||||
printf '%s%s' "$HOME" "$ED"
|
||||
|
||||
cleanup(){
|
||||
tput cnorm
|
||||
exit
|
||||
}
|
||||
trap cleanup INT
|
||||
|
||||
|
||||
tput civis
|
||||
while true
|
||||
do
|
||||
diff=$(( $(date +'%s') - start_time_sec ))
|
||||
ROWS=$(tput lines)
|
||||
COLS=$(tput cols)
|
||||
date --date "@$diff" +'%M:%S' | head -n $ROWS | while IFS= read LINE; do
|
||||
printf '%-*.*s%s\n' $COLS $COLS "$LINE" "$EL"
|
||||
done
|
||||
printf '%s%s' "$ED" "$HOME"
|
||||
sleep 0.1
|
||||
done
|
||||
tput cnorm
|
Reference in New Issue
Block a user