Skip to content

Instantly share code, notes, and snippets.

@jwadolowski
Last active March 16, 2020 11:02
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jwadolowski/622e056478e65341820021b659b5938c to your computer and use it in GitHub Desktop.
Save jwadolowski/622e056478e65341820021b659b5938c to your computer and use it in GitHub Desktop.
brew-upgrade.sh
#!/usr/bin/env bash
(set -x; brew update;)
(set -x; brew upgrade;)
(set -x; brew cleanup;)
red=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0`
casks=( $(brew cask list) )
for cask in ${casks[@]}
do
version=$(brew cask info $cask | sed -n "s/$cask:\ \(.*\)/\1/p")
installed=$(find "/usr/local/Caskroom/$cask" -type d -mindepth 1 -maxdepth 1 -name "$version")
if [[ -z $installed ]]; then
echo "${red}${cask}${reset} requires ${red}update${reset}."
(set -x; brew cask uninstall $cask --force;)
(set -x; brew cask install $cask --force;)
else
echo "${red}${cask}${reset} is ${green}up-to-date${reset}."
fi
done
(set -x; brew cask cleanup;)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment