Files
kymsu2/_homebrew.sh
2018-03-13 06:33:17 +01:00

69 lines
1.7 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Homebrew plugin for KYMSU
# https://github.com/welcoMattic/kymsu
echo "🍺 Homebrew"
brew update
echo ""
brew_outdated=$(brew outdated)
upd3=$(echo "$brew_outdated" | awk '{print $1}')
#brewsy=$(echo "$brew_outdated" | wc -l | awk {'print $1'})
#if [ "$upd3" != "" ]; then
if [ -n "$upd3" ]; then
a=$(echo -e "Do you wanna run \033[1mbrew upgrade "$upd3"\033[0m? (y/n)")
read -p "$a" choice
case "$choice" in
y|Y ) echo "$brew_outdated" | awk '{print $1}' | xargs -p -n 1 brew upgrade ;;
n|N ) echo "Ok, let's continue";;
* ) echo "invalid";;
esac
echo ""
fi
echo "🍺 Casks upgrade."
#brew cask outdated --greedy --verbose | grep -v '(latest)' | awk '{print $1}' | xargs brew cask reinstall
cask_outdated=$(brew cask outdated --greedy --verbose)
outdated=$(echo "$cask_outdated" | grep -v '(latest)')
if [ -n "$outdated" ]; then
echo "$outdated"
echo "$outdated" | awk '{print $1}' | awk '{print $1}' | xargs brew cask reinstall
else
echo -e "\033[4mNo availables Cask updates.\033[0m"
fi
echo ""
latest=$(echo "$cask_outdated" | grep '(latest)')
if [ -n "$latest" ]; then
echo -e "\033[4mCasks (latest):\033[0m"
echo "$latest" | cut -d " " -f1,2
echo ""
read -p "Do you wanna run Cask (latest) upgrade? (y/n)" choice
case "$choice" in
y|Y|o ) echo "$latest" | awk '{print $1}' | xargs -p -n 1 brew cask upgrade --greedy ;;
n|N ) echo "Ok, let's continue";;
* ) echo "invalid";;
esac
fi
echo ""
echo "🍺 The Doc is checking that everything is ok."
brew doctor
brew missing
echo ""
if [[ $1 == "cleanup" ]]; then
echo "🍺 Cleaning brewery"
#brew cleanup -s
brew cleanup --prune=30
#brew cask cleanup
brew cask cleanup --outdated
fi