super simple timer

This commit is contained in:
2020-01-10 12:21:31 +02:00
parent 954a933fcf
commit 8d8a5fe846
2 changed files with 19 additions and 0 deletions

18
reporting/timer Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
function displaytime {
local T=$1
local D=$((T/60/60/24))
local H=$((T/60/60%24))
local M=$((T/60%60))
local S=$((T%60))
printf '\r%s[' $PREFIX
(( $D > 0 )) && printf '%dd ' $D
(( $T > 3599 )) && printf '%02d:' $H
printf '%02d:%02d]%s\r' $M $S $POSTFIX
}
while true; do
displaytime "$SECONDS" >&2
sleep 1
done