feat: add stopwatch

This commit is contained in:
Klesh Wong 2021-09-09 15:48:56 +08:00
parent 31bbdf5547
commit 0cb6a44391

20
bin/stopwatch Executable file
View File

@ -0,0 +1,20 @@
#!/bin/sh
stopwatch() {
local BEGIN=$(date +%s)
echo Starting Stopwatch...
while true; do
local NOW=$(date +%s)
local DIFF=$(($NOW - $BEGIN))
local MINS=$(($DIFF / 60))
local SECS=$(($DIFF % 60))
local HOURS=$(($DIFF / 3600))
local DAYS=$(($DIFF / 86400))
printf "\r%3d Days, %02d:%02d:%02d" $DAYS $HOURS $MINS $SECS
sleep 0.5
done
}
stopwatch