Skip to content

Instantly share code, notes, and snippets.

@xight
Last active February 12, 2017 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xight/c0d4371670722674cbedff67ab461345 to your computer and use it in GitHub Desktop.
Save xight/c0d4371670722674cbedff67ab461345 to your computer and use it in GitHub Desktop.
brew_cask_upgrade.fish
function brew_cask_upgrade
for app in (brew cask list)
set --local latest (brew cask info $app | awk 'NR==1{print $2}')
set --local versions (ls -1 "/usr/local/Caskroom/$app/.metadata/")
set --local current (echo $versions | awk '{print $NF}')
echo "app: $app"
echo "latest: $latest"
echo "versions: $versions"
echo "current: $current"
if [ $latest = "latest" ]
echo "[!] $app: $current == $latest"
if [ $argv[1] = "-f" ]
brew cask install "$app" --force
end
continue
else if [ "$current" = "$latest" ]
continue
end
echo "[+] $app: $current -> $latest"
brew cask uninstall "$app" --force
brew cask install "$app"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment