Skip to content

Instantly share code, notes, and snippets.

@rajatvig
Last active July 6, 2017 07:35
Show Gist options
  • Save rajatvig/33ae5b6be27f3c07d17f to your computer and use it in GitHub Desktop.
Save rajatvig/33ae5b6be27f3c07d17f to your computer and use it in GitHub Desktop.
Fish Functions to Update Brew Casks
function brew_force_update_casks --description 'force update casks that are marked as latest'
set -x _brew_list (brew cask list | grep -Fv '(!)')
for formula in $_brew_list
set -x _info_tmp (brew cask info $formula)
set -x _info (echo $_info_tmp | head -n 3 | grep latest)
if count $_info > /dev/null
brew cask reinstall $formula
end
end
end
function brew_outdated_casks --description 'list outdated casks'
set -x _brew_list (brew cask list | grep -Fv '(!)')
for formula in $_brew_list
set -x _info_tmp (brew cask info $formula)
set -x _info (echo $_info_tmp | head -n 3)
set -x _new_ver (echo $_info | head -n 1 | cut -d' ' -f 2)
set -x _cur_ver (echo $_info | cut -d' ' -f 4 | cut -d/ -f 6)
if test $_new_ver != $_cur_ver
echo "$formula ($_cur_ver < $_new_ver)"
end
end
end
function brew_update_casks --description 'update outdated casks'
set -x _outdated_casks (brew_outdated_casks)
set -x _outdated_cask_names (echo $_outdated_casks | cut -d'(' -f1 | cut -d' ' -f 1)
echo "Outdated Casks $_outdated_cask_names"
for val in $_outdated_cask_names
if [ $val ]
brew cask reinstall $val
end
end
brew cask cleanup
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment