Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SimonSimCity/13832e2e03597a6be793 to your computer and use it in GitHub Desktop.
Save SimonSimCity/13832e2e03597a6be793 to your computer and use it in GitHub Desktop.
Extended the script, written by @streeter to exclude the pinned formulae in the list of formulas to update.
#!/bin/bash
#
# Notify of Homebrew updates via Notification Center on Mac OS X
#
# Author: Chris Streeter http://www.chrisstreeter.com
# Requires: terminal-notifier. Install with:
# brew install terminal-notifier
TERM_APP='/Applications/Terminal.app'
BREW_EXEC='/usr/local/bin/brew'
TERMINAL_NOTIFIER=`which terminal-notifier`
NOTIF_ARGS="-sender com.apple.Terminal"
$BREW_EXEC update 2>&1 > /dev/null
outdated=`$BREW_EXEC outdated --quiet | sed -e 's/.*\///'`
pinned=`$BREW_EXEC list --pinned`
# Remove pinned formulae from the list of outdated formulae
outdated=`comm -1 -3 <(echo "$pinned") <(echo "$outdated")`
if [ -z "$outdated" ] ; then
if [ -e $TERMINAL_NOTIFIER ]; then
# No updates available
$TERMINAL_NOTIFIER $NOTIF_ARGS \
-title "No Homebrew Updates Available" \
-message "No updates available yet for any homebrew packages."
fi
else
# We've got an outdated formula or two
# Nofity via Notification Center
if [ -e $TERMINAL_NOTIFIER ]; then
lc=$((`echo "$outdated" | wc -l`))
outdated=`echo "$outdated" | tail -$lc`
message=`echo "$outdated" | head -5`
if [ "$outdated" != "$message" ]; then
message="Some of the outdated formulae are:
$message"
else
message="The following formulae are outdated:
$message"
fi
# Send to the Nofication Center
$TERMINAL_NOTIFIER $NOTIF_ARGS \
-title "Homebrew Update(s) Available" -message "$message"
fi
fi
@viegelinsch
Copy link

Please change your line 11 to

TERMINAL_NOTIFIER='/Applications/terminal-notifier.app/Contents/MacOS/terminal-notifier'

according to http://superuser.com/a/840204/355334
That fixes at least my problem with this launch agent on 10.10.5 😇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment