diff --git a/stopwatch.sh b/stopwatch.sh index 07275e1..8af5c81 100755 --- a/stopwatch.sh +++ b/stopwatch.sh @@ -1,11 +1,13 @@ #!/bin/sh # 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) -while true; do +stty -echo # hide keyboard input + +while [ true ] +do time="$(($(date +%s) - $start))" printf '%s\r' "$(date -u -d "@$time" +%H:%M:%S)" - sleep 1s; + sleep 1s done