Being the terminal junkie that I am, I often find myself running all sorts of commands and scripts to get things done with minimal interaction on my part. While the command line may seem scary at first, it's a very powerful way to achieve tasks that are not readily made available using the macOS graphical interface. That said, sometimes the default set of tools available through the built-in Terminal.app are not capable of doing everything you need. The good news is you can easily extend this functionality by installing additional packages.
One of the easiest ways to install packages onto your Mac is with Homebrew. It's one of the most popular package managers for macOS and it allows you to install both graphical applications and command line tools very quickly. You can think of it a bit like the Mac App Store for the Terminal, however unlike the Mac App Store, everything in Homebrew is free.
Before you leap into installing Homebrew, you need to ensure your Mac meets the minimum requirements by installing Apple's free Xcode command line tools. If you already have Xcode installed, you won't need to worry about this step, but if you don't you will need to run the following command in the Terminal app to download and install the required components:
If you're unsure, run the command anyway as it will let you know if the tools are already installed.
Once that's complete, you can install Homebrew. The following command will download the latest release from GitHub and start the installation:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
The install script will explain what it's going to do and ask you to confirm. Just follow the on-screen instructions and you should see an "Installation successful!" message when it's complete.
Now you should check that everything is as expected by running the following command:
If there's any problems, just follow the on-screen instructions. Otherwise, you're all ready to brew!
Before you go any further, a really good first step is to prevent Homebrew collecting and reporting any user behaviour telemetry by executing the following command:
brew analytics off
brew command is the way to find and install new packages. It uses simple commands and works similarly to
apt-get on Linux.
You can search the Homebrew repository for new packages by name:
brew search name
If you find one you'd like to install:
brew install package-name
You can also get a list of any of the packages you've installed:
And if you decide you want to uninstall a package you've previously installed:
brew remove package-name
Homebrew is in active development and from time-to-time you'll want to update the components installed on your Mac to ensure that you're always running the latest version. You can quickly and easily do this by running the following command:
This will check online for any new releases of the core Homebrew files and any of the packages you have installed, updating them if necessary.
That's it! You now know the basics for getting started with Homebrew to install new packages and keep them up-to-date. There's a whole lot you can do with Homebrew, and if you'd like to find out more you should visit the Homebrew documentation pages.