Skip to content

Instantly share code, notes, and snippets.

@AlexAti
Created September 23, 2016 16:15
Show Gist options
  • Save AlexAti/81debcfbc3a620a8f3e8132adcb18d19 to your computer and use it in GitHub Desktop.
Save AlexAti/81debcfbc3a620a8f3e8132adcb18d19 to your computer and use it in GitHub Desktop.
A simple script to update and upgrade brew and all casks, copied from somewhere...
#!/usr/bin/env bash
(set -x; brew update;)
(set -x; brew cask update;)
(set -x; brew upgrade;)
(set -x; brew cleanup;)
(set -x; brew cask cleanup;)
red=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0`
casks=( $(brew cask list) )
for cask in ${casks[@]}
do
installed="$(brew cask info $cask | grep 'Not installed')"
if [[ $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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment