Harness the Combinatoric Power of Command-Line Tools and Utilities
Installing Homebrew
Published January 26, 2019 and last verified on December 18, 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.
What You Need
To install Homebrew, you need administrator priviledges on your computer, or permission to install things using the sudo
command.
Installing Prerequisites
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.
Installing Packages with Homebrew
To ensure Homebrew works properly, 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 in your Terminal:
tree --version
You’ll see the version printed to the screen:
tree v2.1.1 © 1996 - 2023 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro
When you install programs on your Mac with Homebrew, the files get placed in the /opt/local/bin
folder on Apple Silicon machines, and in /usr/local/bin
on Intel machines.
Conclusion
Now that you have installed Homebrew, you can use it to install lots of other great tools and programming languages, including GNU versions of command line tools