One of the great things about Mac OS X is the ability to use a traditional shell — Bash — as the native command line interface. However, those accustomed to the rich environment of a Linux Bash shell may miss many of the handy CLI tools that don’t typically come with Mac OS X. Thankfully, there is a very easy-to-use package manager called Homebrew to fill this niche.
Homebrew makes use of the Apple Command Line Tools, which are handy additions to your Mac as well. Downloading the tools is easy but requires registering as an Apple Developer first — it’s fast and free. After logging in, look for something like this:
Homebrew Installation in a Snap
After installing the Apple tools, installing Homebrew is as easy as this one-liner:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Here are some handy management commands to get started:
brew doctor brew search brew info brew upgrade
Once Homebrew is set up, it’s easy to add useful utilities to your Mac; to browse an interactive catalog take a look at Braumeister. Here are some suggestions to try:
An interesting characteristic of Homebrew is that in most cases it actually downloads source code and compiles it for your system. I see this as generally positive, using the genuine version of an app instead of a one-off binary ported and built by an individual. Having said that, a feature known as bottles enables binary packages to be distributed.
Another appealing design attribute is that Homebrew is quite safe to use — it installs everything under /usr/local/ and symlinks from appropriate locations:
$ ls -al /usr/local/bin/wget lrwxr-xr-x 1 eric staff 28 Apr 19 2013 /usr/local/bin/wget -> ../Cellar/wget/1.14/bin/wget
Now that you’re enhancing the Mac command line, it’s time to really up the ante…
Bash Completion on Mac OS X
The Bash shell has a very versatile and productivity-boosting completion mechanism. By default it works like most command shells, automatically expanding directory and file names by hitting ‘tab’ – but there is much more potential, such as completion of hostnames when using ssh. Once Homebrew is up and running, simply do this to enable completion for a broad range of CLI tools:
Edit your .bash_profile as described above to enable completion so you can just hit ‘tab’ to let the productivity begin!