Skip to content

Instantly share code, notes, and snippets.

@tko
Created September 7, 2016 20:08
Show Gist options
  • Save tko/7d47b18a7d61ff902630b09a2ef920c6 to your computer and use it in GitHub Desktop.
Save tko/7d47b18a7d61ff902630b09a2ef920c6 to your computer and use it in GitHub Desktop.
list installed casks that have newer versions available https://caskroom.github.io/
#!/usr/bin/env bash
set -e
contains() {
local needle=$1
for x in "${@:2}"; do
[[ "$x" == "$needle" ]] && return 0
done
return 1
}
main() {
brew cask list --versions | while read -r -a versions; do
cask=${versions[0]}
unset versions[0]
version=$(brew cask _stanza version "${cask}")
if ! contains "${version}" "${versions[@]}"; then
latest=${versions[*]: -1}
if [[ -t 1 ]]; then
echo "${cask}: ${latest} -> ${version}"
else
echo "${cask}"
fi
fi
done
}
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment