Bash functions
a set of commands that can be called numerous times.
https://linuxize.com/post/bash-functions/
add the code lines to your ~/.bashrc
countdown() {
start="$(( $(date '+%s') + $1))"
while [ $start -ge $(date +%s) ]; do
time="$(( $start - $(date +%s) ))"
printf '%s\r' "$(date -u -d "@$time" +%H:%M:%S)"
sleep 0.1
done
}
stopwatch() {
start=$(date +%s)
while true; do
time="$(( $(date +%s) - $start))"
printf '%s\r' "$(date -u -d "@$time" +%H:%M:%S)"
sleep 0.1
done
}
# sleep 0.1` will make the system wait for 1/10th second between each run so you don't spam CPU)