Skip to content

Instantly share code, notes, and snippets.

@handlename
Created February 26, 2013 01:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save handlename/5035062 to your computer and use it in GitHub Desktop.
Save handlename/5035062 to your computer and use it in GitHub Desktop.
notify_start_time=0
notify_end_time=0
notify_threshold=10
notify_threshold2=30
notify_prev_command=""
notify_flag=0
function notify_preexec {
notify_flag=1
notify_start_time=`date +'%s'`
notify_prev_command="$2"
}
function notify_precmd {
if test $notify_flag -eq 0; then
return
fi
notify_flag=0
notify_end_time=`date +'%s'`
notify_elapsed=`expr $notify_end_time - $notify_start_time`
if test $notify_start_time -eq 0; then
return
fi
if test $notify_elapsed -ge $notify_threshold2; then
notify_notify2
elif test $notify_elapsed -ge $notify_threshold; then
notify_notify
fi
}
function notify_notify {
echo "-- notified --"
}
function notify_notify2 {
echo "-- notified2 --"
}
add-zsh-hook preexec notify_preexec
add-zsh-hook precmd notify_precmd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment