Harness the Combinatoric Power of Command-Line Tools and Utilities

../Tutorials

Installing Homebrew

Bash macOS Homebrew

Published January 26, 2019 and last verified on March 10, 2024

With Homebrew, you can install many command line tools, programming languages, and other software quickly. In this tutorial, you’ll install Homebrew on your mac.

Before you install Homebrew, install the XCode Command Line Develper Tools.

Open the Terminal app and execute the following command to start the installation process:

xcode-select --install

You’ll see a license dialog appear. Accept the license and let the installation process complete.

Once it does, you can install Homebrew. The official instructions ask you to execute a remote script you download from GitHub. However, it’s safer to download the script first, inspect it, and then execute it to ensure the script isn’t malicious.

Execute the following command to use curl to download the install script:

curl -fsSL -o install.sh https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh

Use the less command to review the script.

less install.sh

Once you’ve reviewed the script, run the following command to execute the script:

/bin/bash install.sh

The installation process takes some time. It will check your system for any required libraries and prompt you for your password so it can install some additional components. Once the installation completes, you’ll be prompted to execute some commands to add Homebrew to your PATH if you’re using a Mac with an Apple Sillicon chip, or if your existing PATH doesn’t include the directory Homebrew uses. If that’s the case, you’ll see output like this:

- Add Homebrew to your PATH in ~/.zprofile:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

Once you’ve completed the process, you can now use the brew command to install packages.

To test it out, use Homebrew to install the tree command which lets you visualize directory structures.

brew install tree

The command downloads tree and installs it on your Mac.

Test out the tree command

Now that Homebrew is installed, you can use it to install lots of other great tools and programming languages, including GNU versions of command line tools