Notify of background command-line tasks
There are quite a few commands I kick off that are long enough that I start doing something else. Maybe I'm running some regressions tests, maybe I'm building some Java or Actionscript. I don't wait to sit around waiting for it to finish, but I also need to know when it does finish, so I can get on with it.
I wrote a little bash function that helps me keep an eye on these backgrounded tasks.
notify() {
echo Running $1
echo
time $1
if [ $? -eq 0 ] ; then
growlnotify -m "PASSED at $(date)" -t "$2" -s --iconpath '~/Pictures/icons/passed/'
say "success $2 success"
# Whatever else you want to do on success
else
growlnotify -m "FAILED at $(date)" -t "$2" -s --iconpath '~/Pictures/icons/failed/'
say "Failure $2 Failure"
# Whatever else you want to do on failure
fi
}
Add this to your ~/.bash_login, and you'll be set up with a nice little tool. It's easy to use. You can have your 'notify' function execute whatever bash commands you want for success or failure. I made mine pop up a Growl message, and read off a quick message using OS X's say command.
If you go this route, you also need to installl the 'growlnotify' extra that comes with growl so you can access it from the command line.
The first parameter should be the command you want to run (quoted) and the second should be the title of the Growl message you want to pop up.
notify 'ls fake_file' 'Listing a fake file' notify 'ls . ' 'Listing a real directory'

Alert yourself about backgrounded tasks.