Homebrew

Homebrew (or just brew)

The Missing Package Manager for macOS

Find more information under brew.sh

What does Homebrew do?

  • Homebrew installs the stuff you need that Apple didn’t.
    brew install <name>
    
  • Homebrew installs packages to their own directory and then symlinks their files into /usr/local.
  • Homebrew won’t install files outside its prefix and you can place a Homebrew installation wherever you like.
  • It’s all Git and Ruby underneath, so hack away with the knowledge that you can easily revert your modifications and merge upstream updates.
  • Homebrew complements macOS. Install your RubyGems with gem and their dependencies with brew.
  • “To install, drag this icon…” – no more. Homebrew Cask installs macOS apps, fonts and plugins and other non-open source software:
    brew install --cask <name>
    

Bundle

Create a file to save or backup your current brew setup and import it on a new system.

Create a Brewfile that contains all casks/formulae/images/taps. Add --describe to add a description comment above each line

brew bundle dump --describe

Uninstall all dependencies not listed from the Brewfile.

brew bundle cleanup

Check if all dependencies are installed from the Brewfile.

brew bundle check

List all dependencies present in the Brewfile.

brew bundle list

Examples

Find available formulae at formulae.brew.sh/

A few example formulae:

  • nvm
  • OpenJDK
  • Maven
  • ruby
  • youtube-dl
  • zsh-completions
  • zsh-syntax-highlighting

or casks:

  • Firefox
  • Visual Studio Code
  • TextMate
  • Docker
  • Postgres
  • iTerm

Install and Uninstalling formulae or casks

Install

To install a formulae or cask, simply run

brew install <name>

or to be sure, you install the cask

brew install --cask <name>

Uninstall

To uninstall a formulae or cask:

brew uninstall <name>

Autoremove

Some formulae have dependencies on other formulae, therefore those are installed alongside.
However, when you uninstall a formulae, those dependencies are not automatically cleaned up.
To unistall formulae that you didn’t directly installed and which are no longer needed by any other formulae, simply run the autoremove command:

sh brew autoremove

Search

To search for formulae or casks:

brew search <search term>

Update & Upgrade

To check if there are updates for your installed formulae:

brew update

Now, to upgrade those formulae:

brew upgrade

Some casks can be upgraded via brew as well:

brew upgrade --cask

oh-my-zsh support

If you have oh-my-zsh installed, you can add the brew plugin. This adds a couple of short-hand commands, for example:

bubu

which essentially runs

brew update && brew outdated && brew upgrade && brew cleanup

Show Dependencies

brew deps --tree --installed