brew

From RaySoft

brew is the easiest and most flexible way to install the UNIX tools Apple didn’t include with macOS.[1]

Documentation

Syntax

brew SUBCOMMAND [PARAMETER ...] [FORMULA|CASK ...]

Subcommands & Parameters

autoremove
Uninstall formulae that were only installed as a dependency of another formula and are now no longer needed.
cleanup [PARAMETER ...] [FORMULA|CASK ...]
Remove stale lock files and outdated downloads for all formulae and casks, and remove old versions of installed formulae. If arguments are specified, only do this for the given FORMULAe and CASKs. Removes all downloads more than 120 days old.
--prune=DAYS
Remove all cache files older than specified DAYS.
-s
Scrub the cache, including downloads for even the latest versions.
NOTE:
Downloads for any installed formula or cask will still not be deleted. If you want to delete those too: rm -rf $(brew --cache)
.
deps [PARAMETER ...] [FORMULA ...]
Show dependencies for FORMULA. When given multiple FORMULA arguments, how the intersection of dependencies for each formula.
--tree
Show dependencies as a tree. When given multiple FORMULA arguments, show individual trees for each formula.
doctor
Check your system for potential problems. Will exit with a non-zero status if any potential problems are found.
info [PARAMETER ...] [FORMULA|CASK ...]
Display brief statistics for your Homebrew installation.
If FORMULA or CASK is provided, show summary of information about it.
--cask
Treat all named arguments as casks.
--formula
Treat all named arguments as formulae.
--installed
Print JSON of formulae that are currently installed.
install [PARAMETER ...] FORMULA|CASK [...]
Install FORMULA or CASK.
--cask
Treat all named arguments as casks.
-f, --force
Install without checking for previously installed keg-only or non-migrated versions.
--formula
Treat all named arguments as formulae.
list [PARAMETER ...] [FORMULA|CASK ...]
ls [PARAMETER ...] [FORMULA|CASK ...]
List all installed FORMULAe or CASKs.
-1
Force output to be one entry per line. This is the default when output is not to a terminal.
--cask
List only casks.
--formula
List only formulae.
-l
List in long format. If the output is to a terminal, a total sum for all the file sizes is output on a line before the long listing.
-r
Reverse the order of the sort to get the oldest entries first.
-t
Sort by time modified (most recently modified first).
--versions
Show the version number for installed formulae, or only the specified formulae if formula are given.
outdated [PARAMETER ...] [FORMULA|CASK ...]
List installed casks and formulae that have an updated version available. By default, version information is displayed in interactive shells, and suppressed otherwise.
--cask
Only output outdated casks.
--greedy
Print outdated casks with auto_updates or version :latest.
--formula
Only output outdated formulae.
--json
Print output in JSON format.
-q, --quiet
List only the names of outdated kegs.
reinstall [PARAMETER ...] FORMULA|CASK
Uninstall and then install FORMULA or CASK using the same options it was originally installed with, plus any appended options specific to a formula.
--cask
Treat all named arguments as casks.
-f, --force
Install without checking for previously installed keg-only or non-migrated versions.
--formula
Treat all named arguments as formulae.
search [PARAMETER ...] [TEXT|/TEXT/]
Perform a substring search of cask and formula names for TEXT. If TEXT is flanked with slashes, then it is interpreted as a regular expression. The search for text is extended online to homebrew/core and homebrew/cask.
If no text is provided, list all locally available formulae (including tapped ones). No online search is performed.
--cask
Without text, list all locally available casks (including tapped ones, no online search is performed). With text, search online and locally for casks.
--desc
Search for formulae with a description matching text and casks with a name matching text.
--formula
Without text, list all locally available formulae (no online search is performed). With text, search online and locally for formulae.
tap [USER/REPO] [URL]
Tap a formula repository.
If no arguments are provided, list all installed taps.
With URL unspecified, tap a formula repository from GitHub using HTTPS. Since so many taps are hosted on GitHub, this command is a shortcut for brew tap user/repo https://github.com/user/homebrew-repo.
uninstall [PARAMETER ...] FORMULA|CASK
rm [PARAMETER ...] FORMULA|CASK
remove [PARAMETER ...] FORMULA|CASK
Uninstall a FORMULA or CASK.
--cask
Treat all named arguments as casks.
-f, --force
Delete all installed versions of formula. Uninstall even if caskis not installed, overwrite existing files and ignore errors when removing files.
--formula
Treat all named arguments as formulae.
update [PARAMETER ...]
Fetch the newest version of Homebrew and all formulae from GitHub using git and perform any necessary migrations.
-f, --force
Always do a slower, full update check (even if unnecessary).
upgrade [PARAMETER ...] [FORMULA|CASK ...]
Upgrade outdated casks and outdated, unpinned formulae using the same options they were originally installed with, plus any appended brew formula options. If CASK or FORMULA are specified, upgrade only the given cask or formula kegs (unless they are pinned; see pin, unpin).
--cask
Only upgrade outdated casks.
-f, --force
Install without checking for previously installed keg-only or non-migrated versions.
--formula
Only upgrade outdated formulae.
--greedy
Upgrade casks with auto_updates or version :latest

Examples

Install all my tools

~/dev/deploy-apps-libs.sh

Update the system and all my tools

~/dev/maintain-macos.sh

Show dependencies of a formula
brew deps --tree 'ffmpeg'

Output:

ffmpeg
├── aom
├── dav1d
├── fontconfig
│   └── freetype
│       └── libpng
...

References

  1. man 1 'brew'