Last active
February 12, 2017 17:12
-
-
Save xight/c0d4371670722674cbedff67ab461345 to your computer and use it in GitHub Desktop.
brew_cask_upgrade.fish
This file contains 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
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