Dev Setup Using Homebrew on OS X
Package managers make installing, updating, and removing items easy. Unfortunately, OS X does not ship with a package manager. Homebrew to the rescue.
Join the DZone community and get the full member experience.Join For Free
Unfortunately, OS X does not ship with a package manager. Homebrew calls itself “The missing package manager for OS X” and couldn’t be more correct.
Why would you want a package manager for OS X? Have you ever tried to set up Apache, MySQL, and PHP locally? Homebrew can help! No more searching for items and downloading them one by one or doing setup manually.
Before you can install Homebrew you need to have Xcode and its command line tools installed. Xcode can be installed from the App Store.
Xcode’s command line tools can be installed by running xcode-select --install in Terminal.
Once that is done you can install Homebrew with /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)".
To make sure Homebrew installed successfully runbrew --version.
brew install [package name] installs a new package. Test it out with “wget”.
brew uninstall [package name] removes a new package. Use --force if you have multiple versions of the same package installed and want to remove them all.
brew update updates Homebrew’s list of packages and their versions. It does not update any packages themselves to newer versions.
brew outdated lists all the installed packages that have updates available.
brew upgrade [package name] upgrades the package to the latest version. Omit the package name to upgrade all packages.
brew search allows you to search for packages by name. Useful if you want to see what’s available.
brew doctor checks your system for potential problems... The output will tell you what’s wrong and, usually, how to fix it. It’s good to run this after OS X or Xcode update, after adding/removing packages, or about once a month.
Homebrew Cask extends Homebrew, adding the ability to manage applications as well as packages.
Add "cask" after brew in (most of) the commands above when working with casks.
For example, "brew cask search chrome" and "brew cask install google-chrome".
By default applications are installed in the ~/Applications directory so applications are only available to the current user. To install applications for all users use the appdir option - e.g. "brew cask install google-chrome --appdir=/Applications".
Bonus: check out Homebrew fonts for easily installing open-source fonts. No more downloading font files and adding them with Font Book.
Computer Setup Script
Setting up a new machine is a pain. Installing applications, setting up configuration, etc. is time-consuming to do manually. Now that we can install packages and applications on the command line, this can be scripted.
Since you are writing a Bash script, you can do other items besides installing packages and applications with Homebrew. For example, I installed Oh My Zsh.
After you write a script, setting up a new machine is a breeze. Start your script, and let Homebrew do the work while you go get a coffee.
Published at DZone with permission of Emily Miller, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.