[zshrc] add timer function

legacy
Simon Bruder 2018-06-04 18:32:36 +00:00
parent c85f88f5c2
commit 49b84d6ab1
No known key found for this signature in database
GPG Key ID: 6F03E0000CC5B62F
1 changed files with 29 additions and 0 deletions

View File

@ -151,6 +151,35 @@ function ränder() {
)
}
## Timer
function timer() {
(
if [ -z "$1" ] || [ -z "$2" ]; then
echo "USAGE: $0 [u|f] TIME/DURATION" >&2
return 1
fi
if [ "$1" != "u" ] && [ "$1" != "f" ]; then
echo "Invalid mode “$1” supplied. Valid modes are: u|f" >&2
return 2
fi
[ "$1" = "u" ] && mode="until"
[ "$1" = "f" ] && mode="for"
gosleep --${mode} "$2"
if [ "$?" = 0 ]; then
echo "Press CTRL-C to stop the alarm…" >&2
echo -en "\a" # highlight window
play -q ~/Dokumente/sound/ringtones/commando.ogg
else
echo "The sleep command failed. Please check the options." >&2
return 3
fi
)
}
# Bugs
## silversearcher-ag and not apt-get