├── .gitignore ├── brew-update-notifier.gif ├── do-upgrade.sh ├── readme.md ├── install.sh └── check.sh /.gitignore: -------------------------------------------------------------------------------- 1 | log.txt 2 | -------------------------------------------------------------------------------- /brew-update-notifier.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephennancekivell/brew-update-notifier/HEAD/brew-update-notifier.gif -------------------------------------------------------------------------------- /do-upgrade.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TERMINAL_NOTIFIER=`/opt/homebrew/bin/terminal-notifier` 4 | BREW_EXEC='/opt/homebrew/bin/brew' 5 | SCRIPT_DIR=`dirname $0` 6 | LOG="$SCRIPT_DIR/log.txt" 7 | DATE=`date +%Y-%m-%dT%H:%M:%S` 8 | 9 | echo "$DATE Performing update" >> $LOG 10 | 11 | output=`$BREW_EXEC upgrade` 12 | 13 | echo $output >> $LOG 14 | 15 | $TERMINAL_NOTIFIER -title "Homebrew Upgrade Done" -message "$output" 16 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Brew Update Notifier 2 | 3 | Automatically get notifications and apply brew updates on osx 4 | 5 | ![screenshot](https://raw.github.com/stephennancekivell/brew-update-notifier/master/brew-update-notifier.gif) 6 | 7 | ## Install 8 | 9 | ```bash 10 | curl -s https://raw.githubusercontent.com/stephennancekivell/brew-update-notifier/master/install.sh | sh 11 | ``` 12 | 13 | ### Related 14 | 15 | [Search Brew](http://searchbrew.com) the missing search for homebrew. -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "Installing Scripts" 3 | mkdir -p ~/bin/brew-update-notifier 4 | curl -s https://raw.githubusercontent.com/stephennancekivell/brew-update-notifier/master/check.sh -o ~/bin/brew-update-notifier/check.sh 5 | curl -s https://raw.githubusercontent.com/stephennancekivell/brew-update-notifier/master/do-upgrade.sh -o ~/bin/brew-update-notifier/do-upgrade.sh 6 | chmod a+x ~/bin/brew-update-notifier/*.sh 7 | echo "Installing Dependency" 8 | brew install terminal-notifier 9 | 10 | echo "Adding Crontab to run every hour" 11 | (crontab -l ; echo "0 * * * * ~/bin/brew-update-notifier/check.sh > /dev/null 2>&1") | sort - | uniq - | crontab - 12 | -------------------------------------------------------------------------------- /check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Notify of Homebrew updates via Notification Center on Mac OS X 4 | # 5 | # Original Author: Chris Streeter http://www.chrisstreeter.com 6 | # Requires: terminal-notifier. Install with: 7 | # brew install terminal-notifier 8 | 9 | PATH=/usr/local/bin:$PATH 10 | 11 | BREW_EXEC='/opt/homebrew/bin/brew' 12 | TERMINAL_NOTIFIER=`which terminal-notifier` 13 | SCRIPT_DIR=`dirname $0` 14 | DO_UPGRADE="$SCRIPT_DIR/do-upgrade.sh" 15 | LOG="$SCRIPT_DIR/log.txt" 16 | DATE=`date +%Y-%m-%dT%H:%M:%S` 17 | echo $DATE " Checking for updates" >> $LOG 18 | 19 | $BREW_EXEC update 2>&1 > /dev/null 20 | outdated=`$BREW_EXEC outdated | tr ' ' '\n'` 21 | 22 | echo "Found outdated ----" >> $LOG 23 | echo $outdated >> $LOG 24 | echo "----" >> $LOG 25 | 26 | if [ -z "$outdated" ] ; then 27 | if [ -e $TERMINAL_NOTIFIER ]; then 28 | echo "no updates" 29 | #No updates available 30 | # $TERMINAL_NOTIFIER $NOTIF_ARGS \ 31 | # -title "No Homebrew Updates Available" \ 32 | # -message "No updates available yet for any homebrew packages." 33 | fi 34 | else 35 | # We've got an outdated formula or two 36 | 37 | # Nofity via Notification Center 38 | if [ -e $TERMINAL_NOTIFIER ]; then 39 | lc=$((`echo "$outdated" | wc -l`)) 40 | outdated=`echo "$outdated" | tail -$lc` 41 | message=`echo "$outdated" | head -5` 42 | if [ "$outdated" != "$message" ]; then 43 | message="Some of the outdated formulae are: 44 | $message" 45 | else 46 | message="The following formulae are outdated: 47 | $message" 48 | fi 49 | # Send to the Nofication Center 50 | $TERMINAL_NOTIFIER -execute $DO_UPGRADE -title "Homebrew Updates Available" -message "$message" -timeout 10 51 | fi 52 | fi 53 | --------------------------------------------------------------------------------