diff --git a/home/.zshrc.local b/home/.zshrc.local index 670921f..5902ac6 100644 --- a/home/.zshrc.local +++ b/home/.zshrc.local @@ -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