mirror of
https://git.decapod.one/brethil/dotfiles
synced 2024-11-21 11:01:31 +01:00
zsh: functions: add alarm function for quick alarms
This commit is contained in:
parent
1ee73be7f9
commit
faf318c3d0
|
@ -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;
|
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)
|
## Simple http server for current directory (or path)
|
||||||
function httpserver
|
function httpserver
|
||||||
|
|
Loading…
Reference in New Issue
Block a user