Skip to content

Instantly share code, notes, and snippets.

@kane-c
Created May 16, 2017 01:17
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 kane-c/5abd49709e49b7b92eaaf693ac109ca9 to your computer and use it in GitHub Desktop.
Save kane-c/5abd49709e49b7b92eaaf693ac109ca9 to your computer and use it in GitHub Desktop.
Upgrade Brew and all installed packages including casks, then clean up
brew-upgrade() {
(set -x; brew update;)
red=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0`
casks=( $(brew cask outdated) )
for cask in ${casks[@]}
do
version=$(brew cask info $cask | sed -n "s/$cask:\ \(.*\)/\1/p")
echo "${red}${cask}${reset} requires ${red}update${reset}."
(set -x; brew cask uninstall $cask --force;)
(set -x; brew cask install $cask --force;)
done
brew upgrade
(set -x; brew cleanup;)
(set -x; brew cask cleanup;)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment