dotfiles/bin/cask-tidy

21 lines
591 B
Plaintext
Raw Normal View History

2016-03-11 19:49:30 +00:00
#!/bin/bash
[ ! -x "$(which brew 2>/dev/null)" -a ! -d /opt/homebrew-cask ] && exit 1
2016-03-11 19:49:30 +00:00
function __remove-cask {
2016-06-13 08:49:46 +01:00
caskBasePath="/usr/local/Caskroom"
2016-03-11 19:49:30 +00:00
local cask="$1"
local caskDirectory="$caskBasePath/$cask"
local versionsToRemove="$(ls -r $caskDirectory | sed 1,1d)"
if [[ -n $versionsToRemove ]]; then
while read versionToRemove ; do
echo "Removing $cask $versionToRemove..."
rm -rf "$caskDirectory/$versionToRemove"
done <<< "$versionsToRemove"
fi
}
while read cask; do
__remove-cask "$cask"
done <<< "$(brew cask list)"