Skip to content

Instantly share code, notes, and snippets.

@syui
Created May 29, 2015 17:16
Show Gist options
  • Save syui/48505cc28a9373fc2c87 to your computer and use it in GitHub Desktop.
Save syui/48505cc28a9373fc2c87 to your computer and use it in GitHub Desktop.
## zsh/growl integration: any command that takes longer than 5 seconds
## will trigger a growl notification when it completes.
if [ -f /usr/local/bin/terminal-notifier ] ; then
preexec() {
zsh_growl_cmd=$1
zsh_growl_time=`date +%s`
}
precmd() {
if (( $? == 0 )); then
zsh_growl_status=done
else
zsh_growl_status=fail
fi
if [[ "${zsh_growl_cmd}" != "" ]]; then
if (( `date +%s` - ${zsh_growl_time} > 5 )); then
terminal-notifier -message "${zsh_growl_cmd} ${zsh_growl_status}"
fi
fi
zsh_growl_cmd=
}
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment