Brainstorm's snippets (1/261)

  Homebrew Cheatsheet

Homebrew cheatsheet (outdated: some commands - notably switch - have been removed)

Commands

brew install git Install a package
brew uninstall git Remove/Uninstall a package
brew upgrade git Upgrade a package
brew unlink git Unlink
brew link git Link
brew switch git 2.5.0 Change versions
brew list --versions git See what versions you have

More package commands

brew info git List versions, caveats, etc
brew cleanup git Remove old versions
brew edit git Edit this formula
brew cat git Print this formula
brew home git Open homepage
brew search git Search for formulas

Global commands

brew update Update brew and cask
brew list List installed
brew outdated What’s due for upgrades?
brew doctor Diagnose brew issues

Brew Cask commands

brew cask install firefox Install the Firefox browser
brew cask list List installed applications

(*) Cask commands are used for interacting with graphical applications.

Credits:

https://devhints.io/homebrew

See also:

Uninstalling homebrew

From https://osxdaily.com/2018/08/12/how-uninstall-homebrew-mac/:

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

From https://apple.stackexchange.com/questions/82807/how-to-cleanly-remove-homebrew#82808:

cd /tmp
cd `brew --prefix`
rm -rf Cellar
brew prune
rm `git ls-files`
rm -r Library/Homebrew Library/Aliases Library/Formula Library/Contributions
rm -rf .git
rm -rf ~/Library/Caches/Homebrew

Homebrew Multi User Setup

From https://medium.com/@leifhanack/homebrew-multi-user-setup-e10cb5849d59:

  • Create a group brew and add Stan
  • brew doctor (Allen checks if he installed brew correctly)
  • sudo chgrp -R brew $(brew --prefix)/* (Change the group of homebrew installation directory)
  • sudo chmod -R g+w $(brew --prefix)/* (Allow group members to write inside this directory)
  • brew doctor (Stan checks if he can use homebrew)
  • We are done!

Example: How to install a specific version of python3 on OS X

Since switch has been removed from brew, we proceed as follows ...

Install the desided version:

brew install python@3.8

List available versions:

brew list | grep python

    python@3.8
    python@3.9

Change versions:

brew unlink python@3.8
brew unlink python@3.9
brew link --overwrite python@3.8

Check:

python3 --version

    Python 3.8.7