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, check out simple instructions provided on their homepage. Homebrew deals with formulas, which are basically package definitions 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 --versionShows current version (1.1.9 at the time of this post)
brew installInstall formula
brew uninstallUninstall formula
brew updateFetch the newest version of Homebrew from GitHub using git
brew listList 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 doctorCheck your system for potential problems with brew installations
brew info (formula)Display information about formula
brew leavesShow installed formulae that are not dependencies of another installed formula
brew outdatedShow formulae that have an updated version available
brew pruneRemove dead symlinks from the Homebrew prefix
brew reinstall (formula)Uninstall and then install formula
brew tapList all installed taps (A tap is a repository of formulae)
brew untap (tap)Remove a tapped repository
brew --cellarDisplay the location where formula would be installed
brew cleanup (formula)For specific formulae, remove any older versions from the cellar.
brew cleanup -nIt shows what would be removed, but does not actually remove anything
brew cask cleanupcleanup in any installed casks
brew cask listlist all installed casks



Once you have installed homebrew and started using it, maintenance is required regularly 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