Skip to content

Instantly share code, notes, and snippets.

@Jahhein
Created July 5, 2016 09:30
Show Gist options
  • Save Jahhein/52b4f3005c80d8beed6dea70359ad234 to your computer and use it in GitHub Desktop.
Save Jahhein/52b4f3005c80d8beed6dea70359ad234 to your computer and use it in GitHub Desktop.
Homebrew reinstall
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment