Last active
February 16, 2018 05:58
-
-
Save handlename/4696791 to your computer and use it in GitHub Desktop.
notify after heavy command execution.
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_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_threshold; then | |
notify_notify | |
fi | |
} | |
function notify_notify { | |
echo "-- notified --" | |
} | |
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