β
Loading...
Bytes is my collection of short-form posts, tips, and things I learn as I build software.
Ever wanted to run a super simple timer directly from the command line? Oh, you havenβt? Well, you can still read this anyway since you might learn something π.
I built a super basic implementation with a while loop and sleep.
#!/usr/bin/env bash
β
# Check if the user has input a duration for the timer
if [ -z "$1" ]; then
echo "Usage: $0 <minutes> [message]"
exit 1
fi
β
# User settings
duration="$1"
message=${2:-"Timer done!"}
β
# Record the start time
start_time=$(date +%s)
β
# Run the timer
while true; do