Skip to content

Instantly share code, notes, and snippets.

@craSH
Created June 17, 2010 02:50
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 craSH/441624 to your computer and use it in GitHub Desktop.
Save craSH/441624 to your computer and use it in GitHub Desktop.
upgrade brews a-la 'apt-get dist-upgrade'
#!/bin/bash
#
# Very simple script that updates your brew formula repo and
# then upgrades all installed and outdated formulae
# Run with -y to upgrade formulae automatically
#
# Update the repo
brew update
# List of outdated formulae
outdated=$(brew outdated | awk '{print $1}')
# Function that actually upgrades the packages
function upgradebrews() {
for i in $(brew outdated | awk '{print $1}'); do
echo "installing $i"
brew install $i || exit 1
done
}
# Update any out of date ones
if [ -z "$outdated" ]; then
echo "All installed formulae are up to date, nothing to do!"
exit 0
else
echo "About to upgrade the following formulae: $outdated"
if [ "$1" != "-y" ]; then
echo -n 'Proceed with upgrade? (y/n): '
read proceed
if [ "$proceed" == "y" ]; then
echo "Upgrading..."
upgradebrews
else
echo "Aborting..."
exit 0
fi
else
upgradebrews
fi
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment