Compare commits
4 Commits
253bdcbecb
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| c9d04788a7 | |||
| 044850c200 | |||
| 4240b99f84 | |||
| 6bc2145612 |
13
README.md
13
README.md
@@ -1,20 +1,9 @@
|
||||
# CountDown.sh
|
||||
|
||||
A simple script to countdown from a certain number to zero. I made it so that
|
||||
I can easily delay the playing time of songs by a few seconds before I play it
|
||||
on the guitar.
|
||||
|
||||
```
|
||||
USAGE:
|
||||
countdown.sh <sec>
|
||||
|
||||
OPTIONS:
|
||||
<sec> number to countdown from [default: 5]
|
||||
|
||||
EXAMPLE:
|
||||
Countdown from 7 and then play Scott Stapp's "Last Hallelujah"
|
||||
./countdown 7 ; mpv 12_-_Last_Hallelujah.flac
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the terms & conditions of the ZLib license.
|
||||
|
||||
45
countdown.sh
45
countdown.sh
@@ -22,17 +22,48 @@
|
||||
# 3. This notice may not be removed or altered from any source
|
||||
# distribution.
|
||||
|
||||
if [ -z $1 ]
|
||||
set -euo pipefail
|
||||
|
||||
INLINE=0
|
||||
COUNT=5
|
||||
|
||||
if [ $# -ge 1 ] && [ $# -le 2 ]
|
||||
then
|
||||
COUNT=5
|
||||
else
|
||||
COUNT=$1
|
||||
for arg in "$@"
|
||||
do
|
||||
if [ "$arg" = "-i" ]
|
||||
then
|
||||
INLINE=1
|
||||
elif [ "$arg" = "-h" ] || [ "$arg" = "--help" ]
|
||||
then
|
||||
echo "Usage: $0 [-i] [COUNT]"
|
||||
echo " COUNT: Number of seconds to count down from (default: 5)"
|
||||
echo " -i: Inline mode (do not print each number on a new line)"
|
||||
exit 0
|
||||
elif [[ "$arg" =~ [0-9]+ ]]
|
||||
then
|
||||
COUNT="$arg"
|
||||
else
|
||||
echo "Unknown argument: $arg"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
for i in $(seq $COUNT -1 1)
|
||||
for i in $(seq "$COUNT" -1 1)
|
||||
do
|
||||
echo $i
|
||||
if [ $INLINE -eq 0 ]
|
||||
then
|
||||
echo "$i"
|
||||
else
|
||||
printf "\r%s" "$i"
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo 0
|
||||
if [ $INLINE -eq 0 ]
|
||||
then
|
||||
echo "0"
|
||||
else
|
||||
printf "\r%s\n" "0"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user