Created
October 9, 2019 08:57
-
-
Save solrevdev/e513e01d25e08d5bc5abd5a0e5a1cef3 to your computer and use it in GitHub Desktop.
Script upgrading outdated brew casks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
(set -x; brew update;) | |
(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 | |
version=$(brew cask info $cask | sed -n "s/$cask:\ \(.*\)/\1/p") | |
installed=$(find "/usr/local/Caskroom/$cask" -type d -maxdepth 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
curl -s https://gist.githubusercontent.com/solrevdev/e513e01d25e08d5bc5abd5a0e5a1cef3/raw/36808a0544628398f26b48f7a3c7b309872ca2c6/cask_upgrade.sh | bash /dev/stdin