Skip to content

Instantly share code, notes, and snippets.

@awade
Created September 16, 2019 22:55
Show Gist options
  • Save awade/8f02c4ab12d6dca8e5a9770609cf352a to your computer and use it in GitHub Desktop.
Save awade/8f02c4ab12d6dca8e5a9770609cf352a to your computer and use it in GitHub Desktop.
This is a bash script for updating casks pre-"brew cask upgrade" cmd. It catches all version mismatches missed by official cask upgrade methods by doing it manually.
#!/bin/bash
# USE AT YOUR OWN RISK.
# This is a bash script for checking brew cask versions and reinstalling if
# there is a version mismatch. Obviously this may revert casks that have self
# updating to previous version, but then it is as easy as simply updating the
# repo with the cask-repair command. This way the community gets the updates
# too.
brew cask cleanup
brew update
for c in $(brew cask list); do
cask_name=$(echo $c);
cask_ver_local=$(brew cask list $c --versions | cut -d " " -f2);
cask_ver_current=$(brew cask info $c | head -n 1 |tr -d ':' | cut -d " " -f2)
echo "------------"
echo $cask_name
echo "Current installed version: $cask_ver_local"
echo "Version avaliable via cask instalL: $cask_ver_current"
if [ "$cask_ver_local" != "$cask_ver_current" ]; then
echo "...Updating $c to latest"
brew cask reinstall $c
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment