#!/bin/sh
# Brew uninstall -Jahhein
echo "Are you positive you wish to remove brew? Your brews and casks will
be placed into a text file. As always, be sure to trust any shell script you run!"
read -r -p "Are you sure? [y/N] " response
case $response in
[yY][eE][sS]|[yY])
# Create a brews list of formula and casks.
echo "Setting up previously installed brews at ~/Desktop/brewslist.txt"
brew list > ~/Desktop/brewslist.txt
echo "Appending brew casks to brewlist.txt"
brew cask list >> ~/Desktop/brewslist.txt
echo "Removing Cellar"
cd `brew --prefix`
rm -rf Cellar
brew prune
rm -rf Library .git .gitignore bin/brew README.md share/man/man1/brew
rm -rf ~/Library/Caches/Homebrew
echo "Reinstalling brew, checkout your text file on the Desktop to reinstall your brews."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
*)
# Not uninstalled
echo "Homebrew was not removed."
esac