-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbrew-notifier.sh
executable file
·48 lines (43 loc) · 1.54 KB
/
brew-notifier.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/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='/usr/local/Cellar/terminal-notifier/1.7.1/bin/terminal-notifier'
# NOTIF_ARGS="-sender com.apple.Terminal"
$BREW_EXEC update 2>&1 > /dev/null
outdated=`$BREW_EXEC outdated --quiet`
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
$TERMINAL_NOTIFIER \
-title "Homebrew Update(s) Available" -message "$message"
fi
fi