Using Homebrew on MacOSX

How to use the Homebrew package manager on MacOSX and things to keep in mind while using it.

March 11, 2017 - 3 minute read -
#macosx #package

Homebrew

If you have a mac, you need to have homebrew installed on it. It is the best package manager for mac, and in their own words-

Homebrew installs the stuff you need that Apple didn’t.

Homebrew installs packages to their own directory and then symlinks their files into /usr/local. To install homebrew, checkout simple instructions provided on their homepage. Homebrew deals with formulas, which are basically package definition written in Ruby.

Below is a cheatsheet of basic brew commands

With --verbose or -v, many commands print extra debugging information. Note that these flags should only appear after a command.

brew --version Shows current version (1.1.9 at the time of this post)
brew install Install formula
brew uninstall Uninstall formula
brew update Fetch the newest version of Homebrew from GitHub using git
brew list List all installed formulae
brew search text|/text/ Perform a substring search of formula names as string or regex
brew analytics (on|off) Turn on/off Homebrew’s analytics
brew deps (formulae) Show dependencies for formulae
brew desc (formula) Display formula’s name and one-line description
brew doctor Check your system for potential problems with brew installations
brew info (formula) Display information about formula
brew leaves Show installed formulae that are not dependencies of another installed formula
brew outdated Show formulae that have an updated version available
brew prune Remove dead symlinks from the Homebrew prefix
brew reinstall (formula) Uninstall and then install formula
brew tap List all installed taps (A tap is a repository of formulae)
brew untap (tap) Remove a tapped repository
brew --cellar Display the location where formula would be installed
brew cleanup (formula) For specific formulae, remove any older versions from the cellar.
brew cleanup -n It shows what would be removed, but does not actually remove anything
brew cask cleanup cleanup in any installed casks
brew cask list list all installed casks



Once you have installed homebrew and started using it, maintenance is required regualrly to keep the packages up to date, clearing out the old and checking if everything installed is working correctly. Use this command to do all that at once-

brew update && brew upgrade && brew cleanup && brew cask cleanup; brew doctor

or better yet, create an alias of this run that with single word command brewski-

echo "alias brewski='brew update && brew upgrade && brew cleanup && brew cask cleanup; brew doctor'" >> ~/.bash_profile
. ~/.bash_profile
brewski


References

Homebrew
Homebrew - GitHub
Getting Started with Homebrew - Safari Books