Skip to content

Instantly share code, notes, and snippets.

@mstrzele
Last active January 29, 2018 10:35
Show Gist options
  • Save mstrzele/5a4a31f3dfe79e7cae081e0fa66863ab to your computer and use it in GitHub Desktop.
Save mstrzele/5a4a31f3dfe79e7cae081e0fa66863ab to your computer and use it in GitHub Desktop.
Homebrew-Cask upgrade
#!/usr/bin/env bash
outdated() {
local token="${1}"
local info
local cask
local path
mapfile -t info < <(brew cask info "${token}")
read -r -a cask <<< "${info[0]}"
read -r -a path <<< "${info[2]}"
# shellcheck disable=SC2203
[[ $path[0] != *"${cask[1]}"* ]]
}
casks=""
for cask in $(brew cask list); do
if [[ "${cask}" != 'google-chrome' ]] && [[ "${cask}" != 'skype' ]] &&
outdated "${cask}"; then
casks="${casks} ${cask}"
fi
done
if [[ -n "${casks}" ]]; then
# shellcheck disable=SC2086
exec brew cask upgrade ${casks}
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment