Skip to content

Instantly share code, notes, and snippets.

@ysaito8015
Forked from n0ts/brew-cask-upgrade.sh
Last active April 2, 2017 20:43
Show Gist options
  • Save ysaito8015/d33c438ba572aa1e52d0208dabe76350 to your computer and use it in GitHub Desktop.
Save ysaito8015/d33c438ba572aa1e52d0208dabe76350 to your computer and use it in GitHub Desktop.
brew cask upgrade
#!/bin/bash [0/0]
set -Ceu
for c in $(brew cask list); do
info=$(brew cask info $c)
installed_ver=$(echo "$info" |awk 'NR==1' |cut -d" " -f 2)
current_ver=$(echo "$info" |awk 'NR==3' | cut -d" " -f 1 | rev |cut -d"/" -f 1| rev)
if [ "$current_ver" == "latest" ]; then
echo "$c is installed '$installed_ver', current is '$current_ver'"
echo -n "upgrade?[y/n]>"
read INPUT
if [ $INPUT == "y" -o $INPUT == "Y" ]; then
brew cask reinstall $c
else
echo "skip upgrade"
fi
elif [ "$installed_ver" != "$current_ver" ]; then
echo "$c is installed '$installed_ver', current is '$current_ver'"
brew cask reinstall $c
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment