hide keyboard input in stopwatch.sh and reformat
This commit is contained in:
@ -1,11 +1,13 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Simple stopwatch script that simply counts the elapsed time in seconds.
|
# Simple stopwatch script that simply counts the elapsed time in seconds.
|
||||||
# I believe that I stole this code from somewhere many years ago and adapted it to my liking, but I unfortunately do not recall from where.
|
|
||||||
|
|
||||||
start=$(date +%s)
|
start=$(date +%s)
|
||||||
|
|
||||||
while true; do
|
stty -echo # hide keyboard input
|
||||||
|
|
||||||
|
while [ true ]
|
||||||
|
do
|
||||||
time="$(($(date +%s) - $start))"
|
time="$(($(date +%s) - $start))"
|
||||||
printf '%s\r' "$(date -u -d "@$time" +%H:%M:%S)"
|
printf '%s\r' "$(date -u -d "@$time" +%H:%M:%S)"
|
||||||
sleep 1s;
|
sleep 1s
|
||||||
done
|
done
|
||||||
|
Reference in New Issue
Block a user