[zshrc] add timer function
This commit is contained in:
parent
c85f88f5c2
commit
49b84d6ab1
|
@ -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
|
||||
|
|
Reference in a new issue