Apple - Uninstall all programs installed by Homebrew

I usually just do brew remove --force $(brew list).

Edited: brew list now requires the --formula argument, so it should now be

brew remove --force $(brew list --formula)

According to the homebrew FAQ, to uninstall homebrew you use:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

If you don’t want to completely uninstall home-brew but just want to remove all packages installed by homebrew, I think this will do what you need (I’m not currently in a position to remove all of my packages to check):

#Loop while there are still package installed
while [[ `brew list | wc -l` -ne 0 ]]; do
    #Interate over each installed package
    for EACH in `brew list`; do
        #Uninstall each package
        brew uninstall $EACH --force
    done
done

I’ve enclosed the whole thing in a loop double check that after the first run all of the packages have been uninstalled—I’m pretty sure they will be due to the --force option, but belt and braces...

Tags:

Macos

Homebrew