Growl Notifications for Shell Task Completion

(OSX Specific)

I, like many others besides myself often find myself kicking off a process in the shell that takes a minute or two to complete (a large svn commit for example). During that time, I often alt-tab and refresh reddit/slashdot/wikipedia/whatever. It would be great to have something set up that posts a growl notification when the shell process is over.

In my ideal world, it would work like this: “If a process just exited from a tab open in Terminal, post a growl notification.”

Anyone else have something like this set up?

Answer

You can install growlnotify to do this.

$ ./some_program && growlnotify Title -m Message

Of course you would need to think of this before performing your command. The alternative (I don’t know how to achieve this though) would be a Growl notification for every single command, which would be insanely annoying.


To simplify use of growlnotify for your use case, edit ~/bash_profile and add the following:

function long {
    $@
    /usr/local/bin/growlnotify Finished -m 'Done'
}

now you can simply long your_command (similar to sudo). Ctrl-A positions the cursor at the beginning of the line, if you (like me) always type the actual command first and need to add the prefix afterwards.

My bash-fu is unfortunately insufficient to be able to add the command to the growlnotify message


per @mankoff’s comment to this answer:

You can simply type while the command is running, it gets executed afterwards. I created the following function for me:

function gn {
    /usr/local/bin/growlnotify Finished -m "$@"
}

Use as gn svn.

Attribution
Source : Link , Question Author : ezrock , Answer Author : Daniel Beck

Leave a Comment