By Mohamad Wael

Posted :

Brew Cheat sheet

Install homebrew:

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

Uninstall homebrew:

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

Analytics:

brew analytics # Displays analytics state, with UUID


brew analytics on # Turns analytics On


brew analytics off # Turns analytics Off

Available Commands:

brew commands # The available brew commands

Commands Help:

brew help analytics # Shows help
about the analytics command

Report Possible Problems:

brew doctor

Display Brew Configurations:

brew --config

Environment Variables Exports:

brew shellenv # Output environment variables exports,
that can be added to your
shell profile, for example
~/.profile, ~/.bash_profile, or
~/.zprofile, by inserting into
any of them: eval $(brew shellenv)

Cache Path:

brew --cache # Where things get downloaded

Caskroom Path:

brew --caskroom # Path of the caskroom,
a cask is a recipe for installing
a GUI.app macos application
, so this is a path containing
metadata about the casks
that you have installed.

Cellar Path:

brew --cellar # Brew is used
to install Unix applications,
a cellar is where all Unix
applications are installed.

Build Environment:

brew --env # Brew build environment:
for example the used gcc compiler...

Repository Information:

brew --repository # The path on the
local machine, where the brew repository
is synced.


brew --repository user/repo # The path on the local machine,
where a repository containing,
recipes for installing Unix applications,
or a GUI.app macOS applications, is synced


brew --repository homebrew/homebrew-cask # Example


brew --repository homebrew/cask # Example

Update Brew And Installation Recipes:

brew update # To install software,
brew uses formulas, and casks,
located on Git repositories,
synced to your local machine.
A formula, is a recipe for installing
a Unix application.
A cask, is a recipe for installing
GUI.app macOS applications.
So this will update brew,
the formulas, and the casks.

List, Add, Remove Repositories:

brew tap # List repositories,
you are syncing recipes,
for installing, Unix, and
GUI.app macOS applications, from.


brew tap homebrew/homebrew-cask # Adds the Git repository,
homebrew-cask, which can also be referred
using cask, since homebrew-, in the repository
name can be dismissed, and which belongs to
the user homebrew, as a locally synced source
of recipes, from which applications can be installed.


brew tap user/repo URL # In this case,
you must additionally specify,
the URL of the GIT repository,
to be synced.


brew untap homebrew/cask-versions # Remove a repository
from being synced,
as a source of recipes,
usable for software installation.

List Installed Applications:

brew list # List the installed applications,
so the installed formulas, which are the
Unix applications, and casks, which are
the GUI.app, macOS applications.

Listing And Searching Available Applications:

brew formulae # List locally available to install formulas


brew casks # List locally available to install casks


brew search name_any # Search the names,
of locally available to install,
formulas, and casks, if any
contains name_any. Additionally,
the search is extended online, to
homebrew/core, and homebrew/cask


brew search /regular_expression/ # Same as
brew search name_any,
but a regular expression,
as in /n.n/, is used instead.

Downloading Packages:

brew fetch package_name # Fetch casks
and formulas binaries. If a
formula does not have a binary,
fetch its source packages.

Installing/Upgrading Packages:

brew install nginx # Install or upgrade
nginx, from the homebrew/core
repo.


brew install username/repo/nginx #
Install or upgrade nginx,
from the username/repo
repo.


brew install username/repo/nginx --with-modsecurity #
Install or upgrade nginx,
from a thrid party repo
passing in, compilation
options.


brew install tree google-chrome # Install or
upgrade, tree and rmate.

View A formula Installation Options:

brew options nginx # View nginx
formula installation optionss.

Get A Description Of A Formula:

brew desc nginx # One line
description of formula.

Open A Cask Or Formula Homepage:

brew homepage google-chrome # Visit
google chrome homepage.

Show Formula Requirements:

brew deps google-chrome # Show the
dependencies of the
google-chrome cask.

Managing Services:

[sudo] brew services run formula # Run
the application in the
background. For example,
brew services run nginx
runs nginx as the current user,
and:
sudo brew services run nginx,
runs nginx as the root user.


[sudo] brew services start formula # Run
the application in the
background, and register
it, to start at login.


[sudo] brew services stop formula # Stop
the application, and
remove it from starting
at login.


[sudo] brew services restart formula # Stop
the application if running,
run it in the background,
and register it to start at login.


[sudo] brew services # List the
managed services, for the user.


[sudo] brew services cleanup # Remove
unused services.

Upgrade Outdated Packages:

brew upgrade # Upgrade all
installed casks and formulas,
which have a newer version.


brew upgrade adobe-air # Upgrade
adobe-air, if it has, a newer
version.

Forbid/Allow Formula Upgrade:

brew pin mysql # Forbid
the mysql application,
from being upgraded, by
the brew upgrade command


brew unpin mysql # Allow
the mysql application,
to be upgraded.

Uninstall An Application:

brew uninstall atom # Uninstall
the atom cask.

Packages That Require A Formula:

brew uses zlib # Show the
casks, and formulas, that
require the zlib formula,
to be installed.

Leaves:

brew leaves # Show casks,
and formulas, which are
installed,and which are
not dependencies, to
other formulas.


brew leaves --installed-on-request # Show
leaves, installed on request.


brew leaves --installed-as-dependency # Show
leaves, installed, as being
part of a dependency.

Remove Unneeded Installed Dependencies:

brew autoremove # Remove
formulas, which were installed,
as being part of a required
dependency, and are not
needed anymore.

Cleanup:

brew cleanup # Remove
stale lock, and downloaded
files, for a formula, or a cask,
and remove old versions,
of a formula.