Skip to content

Instantly share code, notes, and snippets.

@gonhainu
Last active December 27, 2015 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gonhainu/7302106 to your computer and use it in GitHub Desktop.
Save gonhainu/7302106 to your computer and use it in GitHub Desktop.
Mavericksでコマンド終了時に通知するスクリプト
## zsh integration: any command that takes longer than 3 seconds
## https://gist.github.com/syui/7112389/raw/growl.zsh
## http://qiita.com/kazuph/items/3bfdfce6b7d02b43bf4d
alias pong='perl -nle '\''print "display notification \"$_\" with title \"Terminal\""'\'' | osascript'
preexec() {
zsh_notify_cmd=$1
zsh_notify_time=`date +%s`
}
precmd() {
if (( $? == 0 )); then
# message
zsh_notify_status=done\!\!
else
zsh_notify_status=fail
fi
if [[ "${zsh_notify_cmd}" != "" ]]; then
# time
if (( `date +%s` - ${zsh_notify_time} > 3 )); then
echo ${zsh_notify_cmd} ${zsh_notify_status} | pong
fi
fi
zsh_notify_cmd=
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment