From f08321165ba440e036d42fdf7ae3ee94c35342e0 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 1 Nov 2023 11:44:03 +0000 Subject: [PATCH] hide keyboard input in stopwatch.sh and reformat --- stopwatch.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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