Skip to content

Instantly share code, notes, and snippets.

@kkukelka
Last active December 8, 2022 12:42
Show Gist options
  • Save kkukelka/4d812096028bfb0d22989f79be8103e4 to your computer and use it in GitHub Desktop.
Save kkukelka/4d812096028bfb0d22989f79be8103e4 to your computer and use it in GitHub Desktop.
Homebrew Cheat Sheet

πŸ“Ž Homebrew Cheat Sheet

Install Homebrew (macOS)

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install packages

brew install <package>

Install a formula or cask.

Output installed formulae

brew list

List all installed formulae and casks.

However, various required packages (dependencies) get automatically installed when installing a package using Homebrew. It is possible to view the list of all the installed packages as a nicely formatted dependency tree. To view it, execute the following command: brew deps --tree --installed

Example output:

gdbm

openssl

python
β”œβ”€β”€ gdbm
β”œβ”€β”€ openssl
β”œβ”€β”€ readline
β”œβ”€β”€ sqlite
β”‚   └── readline
└── xz

readline

sqlite
└── readline

brew leaves (reference)

List installed formulae that are not dependencies of another installed formula.

will output a list of all manually? installed formulae -> we can infer that they are safe to uninstall without affecting the operating system

Example output:

ffmpeg
ilmbase
just
szip
vips
youtube-dl

Uninstall package

brew uninstall <package> (reference)

alias: brew remove <package> / brew rm <package>

Uninstall a formula or cask.

Cleanup formulae & dependencies

brew autoremove

Uninstall formulae that were only installed as a dependency of another formula and are now no longer needed.

useful after uninstalling a formulae

brew cleanup

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. This can be adjusted with HOMEBREW_CLEANUP_MAX_AGE_DAYS.

Update packages

brew update

Fetch the newest version of Homebrew and all formulae from GitHub using git(1) and perform any necessary migrations.

brew outdated

List installed casks and formulae that have an updated version available. By default, version information is displayed in interactive shells, and suppressed otherwise.

You can then either upgrade all outdated packages or specify a formula to be upgraded via

brew upgrade | brew upgrade <formula>

Upgrade outdated casks and outdated, unpinned formulae using the same options they were originally installed with, plus any appended brew formula options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment