#!/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 |
Brilliant, thank you 👍
This is sweet! Thanks!
thanks atais for that script!
that is what i was searching ...
cheers
Great script. Much appreciated.
It looks like it stopped working. I know it was working before but now it is not working for my anymore. When I run it everything looks ok. I get no errors.
But I can see that there is new version of cask. for example brew cask info brave
gets me newer version than the one installed. But it isn't upgraded. I also tried with brew cask list | xargs brew cask install --force
and with this, it gets upgraded.
@gasperz I am not sure if that is enough. Current output for brew cask info iterm2
iterm2: 3.0.8
https://www.iterm2.com/
/usr/local/Caskroom/iterm2/3.0.5 (68B)
From: https://github.com/caskroom/homebrew-cask/blob/master/Casks/iterm2.rb
==> Name
iTerm2
==> Artifacts
iTerm.app (app)
iterm2 is up-to-date.
seems that my version is outdated, but...
I can not see any string determining if version is installed here... and finding it out other way will be more complex.
I've just created a slightly modified version of this script and it seems to do the trick for me: https://gist.github.com/jwadolowski/622e056478e65341820021b659b5938c
Additionally it also updates regular brew
packages, not only the cask
ones.
@atais You are correct. It was my mistake. but @jwadolowski solution does work for me. Tested with VirtualBox cask.
Well in the meantime I have raised a question on brew cask
github: Homebrew/homebrew-cask#24412
And got an interesting link: https://github.com/buo/homebrew-cask-upgrade
Have not tried yet.
@jwadolowski I have merged your changes to my gist. Thanks!
There might be an issue with uninstalling the app first, since the download might fail if the network connection is bad, recommending remove the code on L21 since install with --force option would overwrite its ancestor by default.
It is awesome!
Thanks.
Thank you!
This is unfortunately outdated.
Brew no longer uses cask. Now It's brew install --cask
instead of brew cask install
it is an updated version of https://gist.github.com/atais/5d3ec79e67f221cb55b7