Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csrutil/d859f513a0f3ba43ff90956fdfde7014 to your computer and use it in GitHub Desktop.
Save csrutil/d859f513a0f3ba43ff90956fdfde7014 to your computer and use it in GitHub Desktop.
Useful Commands for Package Management in Homebrew

Useful Commands for Package Management in Homebrew

👀 Quick stats

Show Homebrew state:

brew info

Show manually installed taps, kegs and packages in one list:

brew bundle dump --file=-

📦 Manage packages and dependencies

See installed packages

List installed packages:

brew list # formulae and casks
brew list --formulae # just formulae
brew list --casks # just casks

List installed packages which are not dependencies of any others:

brew leaves
brew leaves -r # installed manually
brew leaves -p # installed as dependencies

List installed packages which are not dependencies of manually installed packages:

brew autoremove --dry-run

See dependency tree

Show dependencies of the wget formula in a tree format:

brew deps --tree wget

Show all installed formulae in a dependency tree format:

brew deps --tree --installed
brew deps --tree $(brew leaves) # remove duplicate showing of same dependency

Show dependency tree for all casks:

brew deps --tree $(brew list --casks -1)

Remove hanging dependencies

Uninstall hanging (no longer used) dependencies:

brew autoremove 

Remove all packages

Remove all packages installed with Homebrew:

brew remove --force $(brew list) --ignore-dependencies
brew remove --force $(brew list --formulae) --ignore-dependencies # formulae only
brew remove --force $(brew list --casks) --ignore-dependencies # casks only

🗄️ Manage files

Installation paths

Show key installation directories:

brew shellenv
brew --prefix
brew --repository
brew --cellar
brew --caskroom

See installed files

Show files in the wget keg:

brew list wget # collapse directories
brew list wget --verbose # recurse directories

Show symlinks to the wget keg:

unlink wget --dry-run
unlink wget --dry-run | xargs ls -l # show link destinations

Show unneeded files:

brew cleanup --dry-run # old versions of packages
brew cleanup -s --dry-run # old versions of packages and cache files

Remove unneeded files

Remove old versions of packages and cache files:

brew cleanup -s

Completely erase the Homebrew cache folder:

rm -rf $(brew --cache)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment