Using Homebrew for macOS
Intro
MacOS is an operational system based on Unix kernel, and despite Apple provides an AppStore like some sort of package manager, it lacks a lot of important stuff, specially if you are an advanced user or a developer. With this in mind, community created the Homebrew or just brew project, which is a command line package manager that owns a organised and very extensive repository of packages and apps (casks), and is widely used by Mac users.
In this guide I'll show how to install Homebrew and also some basic commands to install, remove and update packages and apps.
Requirements
- Intel 64 bits processor
- macOS 10.12 or higher
- Command Line Tools (CLT) for Xcode (install it via AppStore or https://developer.apple.com/downloads)
- A shell installation: default terminal (bash), ksh or zsh
Installing
With all requirements installed, brew installation is really easy. Brew is a ruby based project, so, just open your favorite terminal and execute the following command:
/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)
Usage
With Homebrew installed in your machine, open the terminal and start using brew. Use the quick reference below to manipulate packages:
Search for packages and casks
brew search <package or cask approximate name>
List installed packages
brew list
Install package
brew install <package name>
Remove package
brew remove <package name>
Update package
brew upgrade <package name>
or to update all your packages (including homebrew itself)
brew upgrade
Obtaining installed package information
brew info <package name>
Homebrew also has an extension named "cask". Its goal is to provide the same experience of brew core, but for the installation of Mac desktop apps. The usage is quite similar to the previous commands:
Install cask
brew cask install <cask name>
List all installed casks
brew cask list
Remove cask
brew cask remove <cask name>
Update cask
brew cask upgrade <cask name>
or to update all your casks
brew cask upgrade
Obtaining installed cask information
brew cask info <cask name>
Other thing that is worth a lot mentioning is the ability to manage daemons directly from brew, without using the native launchctl.
List executing services
brew services list
Execute service
brew services run <service name>
Stop service
brew services stop <service name>
Restart service
brew services restart <service name>
Conclusion
Homebrew eases the life of macOS users and specially those who are developers. As brew is a very mature and extensive software there may be other abilities not mentioned here in case you want to go deeper. Use the documentation for more information.
See you soon!
Originally published at https://blog.danielpadua.dev on May 5, 2019.