Skip to content

Instantly share code, notes, and snippets.

@tillig
Created February 12, 2021 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tillig/35f4248ce08856127698d7f71987b400 to your computer and use it in GitHub Desktop.
Save tillig/35f4248ce08856127698d7f71987b400 to your computer and use it in GitHub Desktop.
BitBar plugin for checking Homebrew updates
#!/usr/local/bin/bash
# <bitbar.title>Homebrew Updates</bitbar.title>
# <bitbar.author>killercup</bitbar.author>
# <bitbar.author.github>killercup</bitbar.author.github>
# <bitbar.desc>List available updates from Homebrew (OS X)</bitbar.desc>
# Modified by tillig to account for:
# - brew 3 outputs brew update info to stderr
# - putting a 🍺 emoji in the bar helps so it's not just a floating number
exit_with_error() {
echo "err | color=red";
exit 1;
}
/usr/local/bin/brew update > /dev/null 2>&1 || exit_with_error;
PINNED=$(/usr/local/bin/brew list --pinned);
OUTDATED=$(/usr/local/bin/brew outdated --quiet);
UPDATES=$(comm -13 <(for X in "${PINNED[@]}"; do echo "${X}"; done) <(for X in "${OUTDATED[@]}"; do echo "${X}"; done))
UPDATE_COUNT=$(echo "$UPDATES" | grep -c '[^[:space:]]');
echo "🍺$UPDATE_COUNT | dropdown=false"
echo "---";
if [ -n "$UPDATES" ]; then
echo "Upgrade all | bash=/usr/local/bin/brew param1=upgrade terminal=false refresh=true"
echo "$UPDATES" | awk '{print $0 " | terminal=false refresh=true bash=/usr/local/bin/brew param1=upgrade param2=" $1}'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment