Getting Started with Homebrew
2018-09-30
Homebrew is a useful package manager for MacOS that allows you to install, upgrade and do more with the application packages for your projects. Under the hood, the package manager uses Git to download the most updated version of a formula (also called packages).
Before we start, itβs good to know the difference between the commands brew
vs. brew cask
:
brew
command is the core package and is used for formulas with no graphical user interface (GUI).brew cask
command is an extension of brew core and is used for formulas with graphical user interface (GUI).
In this post:
- Homebrew
- Install and Uninstall Homebrew
- Upgrade and Maintain Homebrew
- Homebrew + Formulas
- Install, Upgrade, and Uninstall one Homebrew Formula
- Upgrade all Homebrew Formulas
- Homebrew + Cask Formulas
- Install, Upgrade, and Uninstall one Homebrew Cask Formulas
- Upgrade all Homebrew Cask Formulas
- Sources
Homebrew
Install and Uninstall Homebrew
The command to install Homebrew is on their official website:
# install
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# uninstall
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
Update and Maintain Homebrew
To update and maintain Homebrew, Tania Rascia has a handy Bash alias called brewup in the .bash_profile:
# .bash_profile
alias brewup='brew update; brew upgrade; brew cleanup; brew doctor'
When the above alias is in the .bash_profile
, run brewup in the terminal to run the above commands.
Homebrew + Formulas
To find Homebrew formulas, you can do the following:
- visit Homebrew Official Website β formulas
- run the command
brew search
in the terminal
Install, Upgrade, and Uninstall one Homebrew Formula
- $1 = formula name
# in the terminal
# install, upgrade and uninstall
brew install $1
brew upgrade $1
brew uninstall $1
brew cleanup $1
# about your new installed package $1
brew info $1 # info on formula
$1 --version # check new package version
which $1 # where package is located
Upgrade all Homebrew Formulas
You can use the brew upgrade
without other options to upgrade all formulas in your Cellar.
See how to update formulas in the above section: Homebrew + Formulas > Install, Upgrade, and Uninstall one Homebrew Formula.
Homebrew + Cask Formulas
Add cask
after brew
like so: brew cask
for all cask commands.
Install, Upgrade, and Uninstall one Homebrew Cask Formula
- $2 = cask formula name
# install, upgrade and uninstall
brew cask install $2
brew cask upgrade $2
brew cask uninstall $2
brew cask cleanup $2
# about your new installed package $1
brew info $2 # info on formula
$2 --version # check new package version
which $2 # where package is located
Upgrade all Homebrew Cask Formulas
# in the terminal
brew upgrade # upgrades brew cask core + outdated brew cask formulas