Once you configure a new Mac from scratch, installing a dozen or more apps is an overwhelming job. You have to visit all the application websites and set the apps according to your needs. It takes time and patience.

You can solve this problem with a third-party package manager called Homebrew. It simplifies the installation of Unix tools and popular GUI apps available for Mac. We’ll show you how install apps from Terminal via Homebrew and keep them up to date without any hassle.

What Is Homebrew?

Homebrew is a free and open source package manager that lets you install any kind of app on a Mac, like command-line tools and third-party GUI apps. With a single command, you can search, install, uninstall, or update Unix tools.

The system requirements for Homebrew are:

  • Terminal app
  • macOS Catalina 10.15 or higher (versions 10.10 to 10.14 are supported, but not on the priority list)
  • Command Line Tools for Xcode or Xcode from Mac App Store
  • Bourne-Again Shell (bash) for installation

How to Install Homebrew on a Mac

In order to install Homebrew, you’ll need command-line tools (taking up roughly 200MB). If you already have Xcode installed on your Mac, the package is already built into it. However, you don’t have to install Xcode (which consumes around 10GB or more disk space) just for sake of installing Homebrew.

Step 1: Install Command Line Tools

Open Terminal and run the following command:

xcode-select --install

As you type this command, a popup will appear with the message “xcode-select command requires the command line developer tools. Would you like to install these tools now?” Click the Install button to proceed with the installation. Since I already installed this package, it’s showing an error message, as seen from the screenshot.

install command line tools

Step 2: Install Homebrew

Run the following command from the Homebrew website into Terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

This script will install Homebrew to its preferred location: /usr/local for Intel Macs, /opt/homebrew for M1 Macs, and /home/linuxbrew/.linuxbrew for Linux.

Note: The one-liner installation script requires “bash” shell. Notably, zsh, fish, tcsh, and csh will not work. Since macOS Catalina and above, the default shell is “ZSH,” you may have to switch to “bash” to install Homebrew.

As you paste this command, you’ll see a series of lines about what the script will install and its location. Type in the administrator password and press Return again to continue. The installation process will take some time. You’ll also see an Installation successful message.

successful installation of homebrew

Step 3: Verify the Homebrew Installation

To verify the installation, run:

brew doctor

If you see a Warning message, you don’t have to worry since it only helps the maintainers with debugging if you file an issue. But do check out some common installation issues on the Homebrew website. We also recommend you to run brew doctor periodically.

By definition, a package manager consists of command-line tools and a set of services to automate the software management process like app installation, upgrading, uninstallation, and more. The package consists of software binaries, configuration files, and metadata. The metadata, in turn, handles all the dependencies.

For example, an app might rely on two or more packages to work properly. It will install all the packages and configure the development environment without any trouble of manually installing the tools. Here are some popular Unix tools:

  • youtube-dl lets you download videos from Youtube and other sites.
  • geoip gives you the geolocation data for a particular IP address. Useful for system administrators, security researchers, and web developers.
  • wget lets you download data from the web and from a FTP. You can save a file that’s not downloading from Chrome or even an entire website.
  • htop is a command-line alternative to Activity Monitor for Mac. It gives you thorough information on CPU, memory, processes, and more.
  • pyenv is a tool for managing multiple Python versions. It even lets you switch between multiple versions of Python.

Install and Manage Apps from Terminal Via Homebrew

brew is the core command, central to the entire Homebrew package manager. Formula is a package definition built from the source repository. Cask is an extension to brew that lets you install native apps for Mac though Terminal.

Since the release of earlier iterations of Homebrew (specifically version 1.8.0), many new features and changes were implemented. The minimum OS compatibility was raised to macOS Catalina, brew cask commands were deprecated (with -cask) when necessary, integration with Github Releases was added, and Apple silicon Macs gained support.

To get started, type in the following command to see the list of most essential commands you’ll likely use to manage apps through Homebrew:

brew help

Here’s a list of useful Homebrew formula and cask commands.

1. Install

brew install formula|cask

For example, brew install pyenv and brew install fantastical.

installing a mac app with homebrew cask

2. Uninstall

brew uninstall formula|caskbrew uninstall --force [formula name]brew uninstall --zap [cask name]

When you append -force, it will delete all the installed versions of a formula while ignoring errors when removing files. -zap will remove all files associated with a cask.

Note: It may remove files that are shared between apps.

3. List

brew list formula|caskbrew list --formulabrew list --cask

List all installed formulas and casks. Append -formula to list only formulas and -cask to list casks.

brew list formula and casks

4. Update and Upgrade

brew upgrade formula|cask

Upgrade outdated, unpinned formulas and casks. If you specify a cask or formula, then it’ll only upgrade the given tool. In contrast, brew update reports outdated formulas and suggests brew upgrade.

brew search text|/regex/

Perform a search of cask tokens and formula names for text. You can put a slash beside the text to do a regex search. Append -formula to search online and locally for formulas and -cask to search for casks online or locally.

brew search tactics

6. Outdated

brew outdated formula|caskbrew outdated --formulabrew outdated --cask

List outdated casks and formulas. Append -formula to list the outdated formula, or -cask for an app.

7. Pin and Unpin

brew pin installed_formulabrew unpin installed_formula

Pin a particular formula from getting upgraded when you issue the brew upgrade command. Unpin to upgrade the package.

8. Dependencies

brew deps formula|cask

Shows dependencies for a given formula.

see the dependencies of a formula

9. Cleanup

brew cleanup formula|cask

Removes stale lock files and outdated packages for all formulas and casks. It removes all downloads more than 120 days old.

Cakebrew: The Mac App for Homebrew

Cakebrew is a free, open source app that works in tandem with Homebrew. The app lets you see the list of formulas you have installed, run a quick search, and show the description of formulas you want to install. You can see the list of dependencies required or installed for a given formula.

cakebrew mac app for homebrew

It even supports Homebrew/bundle to export and import your formulas. If you like Homebrew, but don’t want to use the command line for every purpose, this app will prove useful. To install cakebrew, type in:

brew install cakebrew

Within minutes, you’ll see the app in the /Applications folder.

Homebrew and Cask Workflow for Alfred

The Homebew and cask workflow for Alfred lets you easily install, uninstall, and manage Homebrew and casks in tandem. The script filters brew and cask with support of every important command, like doctor, install, list, search, uninstall, and more.

manage brew and cask with alfred

Launch Alfred, then type in brew or cask to manage apps right from Alfred. You need to have Alfred Powerpack to use this workflow.

Install Open Source Apps With Homebrew

Homebrew is a great package manager to install apps via Terminal on Mac. If you’re setting up a Mac from scratch, or work in a company where you manage multiple Macs, it can save you a lot of time and energy.

For the beginner, it’s easy to get lost with all these commands, but you don’t have to hurry. Go slow with these steps and note down the commands. After installing Homebrew, try installing some lesser known open source Mac apps as your homework.