Created
February 26, 2013 01:41
-
-
Save handlename/5035062 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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