-
-
Save joshmanders/515d869a1fc059a1692c20ecdbaae2d3 to your computer and use it in GitHub Desktop.
Homebrew Cask Upgrade
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 | |
readonly local caskroom="/usr/local/Caskroom" | |
upgrade () { | |
casks=($(brew cask list)) | |
for cask in ${casks[@]}; do | |
current="$(brew cask info ${cask} | sed -n '1p' | sed -n 's/^.*: \(.*\)$/\1/p')" | |
installed=($(ls ${caskroom}/${cask})) | |
if (! [[ " ${installed[@]} " == *" ${current} "* ]]); then | |
echo "Upgrading ${cask} to v${current}." | |
(set -x; brew cask install ${cask} --force; rm -rf ${caskroom}/${cask}/${installed[@]}) | |
else | |
echo "${cask}@${current} already installed." | |
fi | |
done | |
} | |
main () { | |
local args=("$@") | |
case "$1" in | |
upgrade) upgrade "${args[@]}" ;; | |
*) brew cask "${args[@]}" ;; | |
esac | |
} | |
main "$@" |
@ibrokemypie sorry I missed this comment, no it doesn't. It just loops through and updates all casks like brew upgrade
does.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
does this support upgrading a single cask supplied as an arg?