✨ Added stopwatch bash script
This commit is contained in:
parent
86b4d5944b
commit
9253ce9bfc
1 changed files with 26 additions and 0 deletions
26
scripts/stopwatch
Executable file
26
scripts/stopwatch
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env bash
|
||||
stopwatch() {
|
||||
start=$(date +%s)
|
||||
while true; do
|
||||
days="$(($(( $(date +%s) - $start )) / 86400))"
|
||||
time="$(( $(date +%s) - $start ))"
|
||||
printf '%s day(s) and %s\r' "$days" "$(date -u -d "@$time" +%H:%M:%S)"
|
||||
sleep 0.1
|
||||
done
|
||||
}
|
||||
|
||||
stopwatch "${@}"
|
||||
|
||||
# countdown() {
|
||||
# start="$(( $(date +%s) + $1))"
|
||||
# while [ "$start" -ge $(date +%s) ]; do
|
||||
# ## Is this more than 24h away?
|
||||
# days="$(($(($(( $start - $(date +%s) )) * 1 )) / 86400))"
|
||||
# time="$(( $start - `date +%s` ))"
|
||||
# printf '%s day(s) and %s\r' "$days" "$(date -u -d "@$time" +%H:%M:%S)"
|
||||
# sleep 0.1
|
||||
# done
|
||||
# }
|
||||
|
||||
# Taken from:
|
||||
# https://superuser.com/questions/611538/is-there-a-way-to-display-a-countdown-or-stopwatch-timer-in-a-terminal
|
||||
Loading…
Add table
Add a link
Reference in a new issue