Created
February 23, 2012 10:20
-
-
Save kyanagi/1892120 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
if type growlnotify > /dev/null 2>&1 | |
then | |
GROWL_REPORTTIME=5 | |
COMMAND= | |
COMMAND_START_TIME=0 | |
function reset_command_start_time { | |
COMMAND="${1}" | |
COMMAND_START_TIME=`date +%s` | |
echo $COMMAND | |
} | |
function notify_heavy_job_finished_on_growl { | |
if (( COMMAND_START_TIME > 0 )); then | |
local t=`date +%s` | |
if (( t - COMMAND_START_TIME > GROWL_REPORTTIME )); then | |
COMMAND="$COMMAND " | |
growlnotify -t "${${(s: :)COMMAND}[1]}" -m "$COMMAND" | |
fi | |
fi | |
COMMAND= | |
COMMAND_START_TIME=0 | |
} | |
add-zsh-hook preexec reset_command_start_time | |
add-zsh-hook precmd notify_heavy_job_finished_on_growl | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment