Skip to content

Commit

Permalink
fix: update cask functions
Browse files Browse the repository at this point in the history
  • Loading branch information
seantrane committed Dec 23, 2019
1 parent f87e63d commit 58015f6
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 48 deletions.
30 changes: 23 additions & 7 deletions functions/cask_info
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,28 @@
# Homebrew Cask Info

cask_info () {
echo "\nHomebrew Cask Info...\n"
for c in $(brew cask list); do
brew cask info $c
echo "\nContents of /opt/homebrew-cask/Caskroom/$c/..."
ls -1 /opt/homebrew-cask/Caskroom/$c
echo ""
echo "Homebrew Cask Info..."
if [[ "$1" ]]; then
brew cask info "$1"
if [[ -d "/usr/local/Caskroom/$1" ]]; then
echo "Contents of /usr/local/Caskroom/$1/..."
ls -1 "/usr/local/Caskroom/$1"
elif [[ -d "/opt/homebrew-cask/Caskroom/$1" ]]; then
echo "Contents of /opt/homebrew-cask/Caskroom/$1/..."
ls -1 "/opt/homebrew-cask/Caskroom/$1"
fi
else
for cask_name in $(brew cask list); do
brew cask info "$cask_name"
if [[ -d "/usr/local/Caskroom/$1" ]]; then
echo "Contents of /usr/local/Caskroom/$cask_name/..."
ls -1 "/usr/local/Caskroom/$cask_name"
elif [[ -d "/opt/homebrew-cask/Caskroom/$1" ]]; then
echo "Contents of /opt/homebrew-cask/Caskroom/$cask_name/..."
ls -1 "/opt/homebrew-cask/Caskroom/$cask_name"
fi
echo ""
done
echo ""
fi
echo ""
}
28 changes: 14 additions & 14 deletions functions/cask_install
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
# Supports install and reinstalling casks.

cask_install () {
if [ "$1" ]; then
echo "Removing brew cache"
rm -rf "$(brew --cache)"
echo "Running brew update"
brew update
if [ -d "/opt/homebrew-cask/Caskroom/$1" -o -d "/usr/local/Caskroom/$1" ]; then
echo "Uninstalling $1"
brew cask uninstall --force "$1"
echo "Re-installing $1"
else
echo "Installing $1"
fi
brew cask install "$1"
if [[ "$1" ]]; then
echo "Removing brew cache"
rm -rf "$(brew --cache)"
echo "Running brew update"
brew update
if [[ -d "/opt/homebrew-cask/Caskroom/$1" ]] || [[ -d "/usr/local/Caskroom/$1" ]]; then
echo "Uninstalling $1"
brew cask uninstall --force "$1"
echo "Re-installing $1"
else
echo "No cask provided: $1"
echo "Installing $1"
fi
brew cask install "$1"
else
echo "No cask provided: $1"
fi
}
54 changes: 27 additions & 27 deletions functions/cask_upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@
# Supports iterative/optional upgrading of all installed casks.

cask_upgrade () {
if [ "$1" != '--continue' ]; then
echo "Removing brew cache"
rm -rf "$(brew --cache)"
echo "Running brew update"
brew update
fi
for c in $(brew cask list); do
echo -e "\n\nInstalled versions of $c: "
ls /opt/homebrew-cask/Caskroom/$c
echo "Cask info for $c"
brew cask info $c
select ynx in "Yes" "No" "Exit"; do
case $ynx in
"Yes" )
echo "Uninstalling $c"
brew cask uninstall --force "$c"
echo "Re-installing $c"
brew cask install "$c"
break;;
"No" )
echo "Skipping $c"
break;;
"Exit" )
echo "Exiting brew-cask-upgrade"
return;;
esac
done
if [[ "$1" != '--continue' ]]; then
echo "Removing brew cache"
rm -rf "$(brew --cache)"
echo "Running brew update"
brew update
fi
for cask_name in $(brew cask list); do
echo -e "\n\nInstalled versions of $cask_name: "
ls "/opt/homebrew-cask/Caskroom/$cask_name"
echo "Cask info for $cask_name"
brew cask info "$cask_name"
select ynx in "Yes" "No" "Exit"; do
case $ynx in
[yY] | [yY][Ee][Ss] )
echo "Uninstalling $cask_name"
brew cask uninstall --force "$cask_name"
echo "Re-installing $cask_name"
brew cask install "$cask_name"
break;;
[nN] | [n|N][O|o] )
echo "Skipping $cask_name"
break;;
* )
echo "Exiting brew-cask-upgrade"
return;;
esac
done
done
}

0 comments on commit 58015f6

Please sign in to comment.