Manage macOS packages with Homebrew
Homebrew is a package manager for macOS that allows users to easily install and manage software packages and libraries. It uses a command-line interface and a simple formula system to download and install packages from pre-configured sources, making it easy to keep software up to date and manage dependencies. To install Homebrew, open Terminal and run the following command:
This will download and run the Homebrew installation script. Once installed, you can use Homebrew to install packages by running commands like
brew install <package>. For example, to install the
wget package, you would run:
If you’re unsure of the name of the package, or if it is available from homebrew, you can search for it using
brew search <package>, including applications like Google Chrome.
google-chrome is listed under the
Casks section, which means it is a graphical application. To install it, you run the install command with the cask flag:
Adding a custom tap
A Homebrew tap is a repository of additional formulae that are not included in the main Homebrew repository. Adding a custom Homebrew tap allows you to install software that is not available in the main repository. Here’s how to add a custom Homebrew tap:
You can also create your own tap to add homebrew support to your favorite packages and applications.
Keeping Homebrew up-to-date
To keep your packages and libraries up-to-date, Homebrew offers multiple commands. I recommend running the following commands in this order to ensure you have the latest versions of your packages and libraries.
brew updateupdates the local Homebrew repository with the latest version of package information from the remote repository. This ensures that you have the latest versions and dependencies of packages available to install or upgrade on your system.
brew outdatedlists all installed packages that have a newer version available in the remote repository. This command helps you identify which packages are outdated and need to be updated. This is optional but provides a preview of how many packages are going to update when running the next command.
brew upgradeupgrades all outdated packages installed on your system to their latest versions available in the remote repository. This command updates the packages to their latest versions, including all their dependencies, and ensures that your system has the most up-to-date software.
brew cleanup --prune=allremoves old versions of installed packages and their associated files, freeing up disk space. The
--prune=alloption removes all packages and their associated files, including those that are currently installed and those that are no longer needed. This command is useful when you want to reclaim disk space on your system by removing old and unused packages. However, it is recommended to use this command with caution, as it can potentially remove files that are still needed by other packages or applications.
brew doctordiagnoses potential issues with your Homebrew installation. This command checks your Homebrew installation for common issues, such as outdated packages, broken symlinks, and other configuration problems. It also provides suggestions on how to fix any issues that it finds.
I have wrapped everything you need to keep homebrew up-to-date. I will typically run this script a few times per week. Here’s how to create it.
The only dependency is a CLI tool called gum, which is a tool for glamorous shell scripts. Install it running the following command.
Then, create a file name
b in the
~/.config/bin directory. I find this to be a useful place to create custom scripts to automate repetitive tasks.
Then, add the following content to the file.
You need to make the
b script executable, add the
~/.config/bin directory to your path, on the default macOS shell, then source the zshrc for the PATH to reflect the new directory.
Finally, you can run the
b command in your terminal to ensure you have the latest versions of my favorite packages and applications which includes bug fixes, security updates, and new features. But be careful, if there are breaking changes to a package, you may need to update your configuration to support the new version. You can visit the package’s release notes to see what has changed.
In summary, Homebrew is a package manager for macOS that simplifies the installation and management of software packages and libraries. It uses a command-line interface and a simple formula system to download and install packages from pre-configured sources using
brew install, making it easy to keep software up-to-date and manage dependencies. To add a custom tap, you can use the
brew tap command to add a repository of additional formulae that are not included in the main Homebrew repository. To keep Homebrew up-to-date, you can use
brew cleanup, and
brew doctor commands. I also showed you a simple
b script that automates these commands for an easy way to stay up-to-date.
Sign-Up for New Posts
Stay in the loop and get the latest blog posts about dotfiles sent to your inbox.