diff --git a/functions/misc.zsh b/functions/misc.zsh index 5e41396..82c1c75 100755 --- a/functions/misc.zsh +++ b/functions/misc.zsh @@ -69,6 +69,30 @@ function beeper while true; do printf "\e[?5h\007"; sleep 0.25; printf "\e[?5l"; read -s -n -t1 && break; done; } +# set an alarm in seconds, minutes, hours +function alarm { + if [[ -z $1 ]]; then + echo "Usage: alarm 5[s]|5m|1h" + return 1 + fi + local t + if [[ $1 = *"m" ]]; then + t=$((${1/m/}*60)) + extra="($1)" + elif [[ $1 = *"h" ]]; then + t=$((${1/h/}*3600)) + extra="($1)" + elif [[ $1 = *"s" ]]; then + t=${1/s/} + else + t=$1 + fi + + echo "Setting a timer for $1 $extra" + + sleep $t && beeper +} + ## Simple http server for current directory (or path) function httpserver