Skip to content

Instantly share code, notes, and snippets.

@poolik
Created February 16, 2014 08:54
Show Gist options
  • Save poolik/9031329 to your computer and use it in GitHub Desktop.
Save poolik/9031329 to your computer and use it in GitHub Desktop.
Notifications from terminal
function notifyDone () { command="$@"; terminal-notifier -title "Terminal" -message "Done with '$command'!" -activate com.googlecode.iterm2; }
function notifyError () { command="$@"; terminal-notifier -title "Terminal ERROR!" -message "'$command' exited with error!" -activate com.googlecode.iterm2; }
function wn () { ($@ && notifyDone $@) || notifyError $@; }
function n () { $@; notifyDone $@;}
# Usage:
# if command returns 0 on success and non 0 on error:
wn git push heroku production:master
# else
n git push heroku production:master
terminal-notifier -title "First test" -message "Notification from terminal"
alias notifyDone='terminal-notifier -title "Terminal" -message "Done with command!"'
alias notifyError='terminal-notifier -title "Terminal ERROR!" -message "Command exited with error"'
# Usage:
# if command returns 0 on success and non 0 on error:
(git push heroku production:master && notifyDone) || notifyError
# else
git push heroku production:master; notifyDone;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment