Notification Center Updates for Homebrew
I’ve modified my Homebrew update notification script to use Notification Center thanks to terminal-notifier, a growlnotify replacement that allows posting to Notification Center from the command line. The script now looks like this:
export PATH=/usr/local/bin:$PATH
notifier=/Applications/terminal-notifier.app/Contents/MacOS/terminal-notifier
# Give the network a chance to connect
sleep 10
brew update > /dev/null 2>&1
outdated=`brew outdated | sort | tr '\n' ' '`
if [ ! -z "$outdated" ]; then
$notifier \
-group net.codeworkshop.homebrewupdate \
-title "Homebrew Updates Available" \
-message "$outdated" \
-activate com.apple.Terminal > /dev/null 2>&1
fi
The launch agent remains the same, checking for updates every day at 6:00 p.m. or the next time the Mac wakes from sleep. To install, first download terminal-notifier and place it in your Applications folder. Then download the script files and move homebrewupdate into /usr/local/bin and net.codeworkshop.homebrewupdate.plist into ~/Library/LaunchAgents. Then load the launch agent and you should be set.
launchctl load ~/Library/LaunchAgents/net.codeworkshop.homebrewupdate.plist
If you’re upgrading from the Growl version you only need to replace the homebrewupdate script. The launch agent works just as before.