Using Growl for long-running scripts

10 Jan 2012

Often it's nice to know when a long-running process has finished without having to continually check the terminal it's running in. I use this small function to call Growl to notify me when a command has finished.

function gn {
    /usr/local/bin/growlnotify -m "Starting \"$*\""
    $*
    if [ $? == 0 ]; then
        /usr/local/bin/growlnotify -m "\"$*\" succeeded"
    else
        /usr/local/bin/growlnotify -m "\"$*\" failed"
    fi
}

This simply wraps the command in a couple of calls to growlnotify. Add this to your ~/.bash_profile and simply prepend gn to your long-running command

source ~/.bash_profile
gn nvm install v0.6.7

Comments