Counts down a number of seconds before exiting.
This is useful as an alternative to
read, to give users a chance to exit multi-part shell scripts.
npm install -g cli-countdown
echo Doing interesting things...echo Now about to delete some filescountdown -m "Deleting files in" -s 10rm foo.txt
- If the timer runs to the end, the exit code will be
- If the user interrupts with
SIGINT), the exit code will be
If you want
Ctrl-C to abort the current shell script completely, you will probably want to use
set -eat the top of your script
countdown <args> || exit 1
countdown -s 10: timer duration in seconds (default 10)
countdown -m "message": message to display (default none)