How to get a notification when my commands are done

I'm running a series of commands on the command line that takes approximately twenty minutes to complete. I'd like to see some sort of notification on my Mac when these are finished so I don't need to monitor the terminal for when it finishes. Is there a way to do this?

$ svn update . && ant clean build start && *notify_me_somehow*

Edit:

I could use xclock but this seems like a hack. Ideally I could send the notification anywhere, like my phone, screen, etc.


(svn update . && ant clean build start && say done) || say error


In Mac OS 10.8 and above you can send yourself Notification Center messages. There's a tool called terminal-notifier that you can download or install using Homebrew or Rubygems, e.g.:

brew install terminal-notifier

Check out https://github.com/julienXX/terminal-notifier for more on this tool.

To simplify the common use-case of just caring about the fact of something in the terminal being done, add an alias to your .bash_profile:

alias notifyDone='terminal-notifier -title "Terminal" -message "Done with task! Exit status: $?"' -activate com.apple.Terminal

Or, incorporating Austin Lucas' answer, you can add a sound and icon badge with tput bel:

alias notifyDone='tput bel; terminal-notifier -title "Terminal" -message "Done with task! Exit status: $?"' -activate com.apple.Terminal

Then you can simply do:

$ <long-running task> ; notifyDone

Once the long-running task finishes you'll get a nice modal popup:

Notification Center popup

When you click the notification, it will activate Terminal. If you go to System Preferences > Notifications > terminal-notifier and change the alert style to "Alerts", the notification will persist until you dismiss it.


Use Growl.

In the .dmg file, look for the extras, there's a growlnotify binary. Install it, something like in /usr/local/bin. Then you can use this command

growlnotify --sticky --appIcon <icon> --message <message> -t <title>

to show a popup, like that:

growl