homebrew_update_notifier/homebrew-update-notifier.sh

47 lines
1.5 KiB
Bash
Raw Permalink Normal View History

2011-01-30 22:04:19 +00:00
#!/bin/bash
#
2011-01-31 00:07:04 +00:00
# Notify of Homebrew updates via Growl on Mac OS X
#
# Original Author: Chris Streeter http://www.chrisstreeter.com
# Original Homepage: https://github.com/streeter/dotfiles/blob/master/bin/port-update-notifier
#
# Ported to Homebrew by: Andrew Davidson http://amdavidson.com
# Homepage: http://github.com/amdavidson/homebrew-update-notifier
2011-01-30 22:04:19 +00:00
#
# Requires: Growl Notify Extra to be installed (but fails gracefully). Info
# about how to get the extra is at http://growl.info/extras.php
2011-01-31 00:07:04 +00:00
TERM_APP='/Applications/Utilities/Terminal.app'
BREW_EXEC='/usr/local/bin/brew'
2011-01-30 22:04:19 +00:00
GROWL_NOTIFY='/usr/local/bin/growlnotify'
2011-01-31 00:07:04 +00:00
GROWL_TITLE="Homebrew Update(s) Available"
2014-12-12 03:02:56 +00:00
GROWL_ARGS="-n 'MacPorts' -d $GROWL_NOTIFY -a $BREW_EXEC"
2011-01-30 22:04:19 +00:00
2014-12-12 03:02:56 +00:00
$BREW_EXEC update > /dev/null 2>&1
2011-01-31 00:07:04 +00:00
outdated=`$BREW_EXEC outdated`
2011-01-30 22:04:19 +00:00
2011-01-31 00:07:04 +00:00
if [ -z $outdated ] ; then
2011-01-30 22:04:19 +00:00
if [ -e $GROWL_NOTIFY ]; then
# No updates available
2014-12-12 03:02:56 +00:00
$GROWL_NOTIFY $GROWL_ARGS -m '' -t "No Homebrew updates available"
2011-01-30 22:04:19 +00:00
fi
else
# We've got an outdated port or two
# Nofity via growl
if [ -e $GROWL_NOTIFY ]; then
lc=$((`echo "$outdated" | wc -l` - 1))
outdated=`echo "$outdated" | tail -$lc | cut -d " " -f 1`
message=`echo "$outdated" | head -5`
if [ "$outdated" != "$message" ]; then
message="Some of the outdated packages are:
$message"
else
message="The following packages are outdated:
$message"
fi
# Send to growlnotify
2011-01-31 00:07:04 +00:00
echo "$message" | $GROWL_NOTIFY $GROWL_ARGS -t $GROWL_TITLE
2011-01-30 22:04:19 +00:00
fi
fi