Skip to content

Instantly share code, notes, and snippets.

@jaymecd
Created December 2, 2013 14:24
Show Gist options
  • Save jaymecd/7750203 to your computer and use it in GitHub Desktop.
Save jaymecd/7750203 to your computer and use it in GitHub Desktop.
Brew cask helpers (OSX)
function cask_install() {
if brew cask info "${@}" | grep "Not installed" > /dev/null; then
brew cask install "${@}"
else
echo "${@} is already installed."
fi
}
function cask_upgrade() {
if brew cask info "${@}" | grep "Not installed" > /dev/null; then
echo "${@} is not installed."
else
brew cask install --force "${@}"
fi
}
function cask_cleanup() {
local caskroom="/opt/homebrew-cask/Caskroom"
for app in $(/usr/bin/find "$caskroom" -depth 1 -type d); do
if [[ $(/usr/bin/find "$app" -depth 1 -type d | wc -l) -gt 1 ]]; then
echo -n "$(basename "$app"):"
for version in $(/bin/ls -1t "$app" | /usr/bin/tail -n+2); do
echo -n " $version "
rm -rf "$app/$version"
done
echo
fi
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment