Homebrew is a package management system for OS X. You can read more about it here, or simply run
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
to install it.
First things first, you need to familiarize yourself with some of the basic homebrew commands.
All commands start with the binary
If you are looking for something in particular, you can first search for it to see if homebrew has a formulae for what you're looking for. For example, running
brew search tree will return
mvptree pstree tree treecc treeline
Once you find the formulae you're looking for, you can run
brew install tree.
other important commands
brew list- List all installed formulae
brew update– Fetch the newest version of Homebrew and all formulae form GitHub using git.
brew upgrade [formulae]– Upgrade outdated formulae. This can take an optional argument if you only want to update one formulae
brew uninstall <formulae>– uninstall a specific formulae
There are a myriad of other commands and tasks you can run that we won't discuss in detail here. Running
man brew or reading the documentation linked on Homebrew's main page.
Now that you know how Homebrew functions, let's get into so of the best packages to install.
Right off the bat, brew is useful for things like git, vim, zsh, tmux, and many more base level tools that a lot of developers normally already have. We're going to look at some lesser known packages, but just know that Homebrew is getting larger, and almost anything that you would want that runs in the terminal is available as a homebrew package. If it isn't, it's incredibly easy to make it yourself. More on this later.
brew install hub
This is easily one of my favorites. You can think of
hub as all the same functionality of
git, but with add-ons that make it compatible with GitHub.
When you're deep in the codebase and realize that you haven't commited any of your hard work to GitHub, it's annoying to have to jump over to your browser, surf to https://github.com, create a new repo, etc. That context switch just pulled you away from your important work and forced you to interact with – gulp – a GUI interface. How unfitting.
This is where
hub comes into play. Important tasks that you were once only able to do through GitHub are now available via the terminal. Want to create a new remote repo and automatically set GitHub as the origin?
hub create. Want to open a pull request?
hub pull-request. Want to view your remote repo on GitHub from any sub-directory?
hub browse. Of course this is not an exhaustive list of commands for
hub --help or
man hub for more information, customizing flags, and other goodies.
brew install the_silver_searcher
A quick and dirty way to search through any file structure for a key word or phrase.
You're in your Rails app and need to find all instances of
ag is used for two reasons: 1) it would be awful to type
the_silver_seracher before everything you want to search, 2) AG is the symbol for the chemical element silver. A common flag includes running the search with
--context, which will print out the lines before and after the key phrase.
Some of you may be thinking, yeah, but I already have grep (or ack) which serves the same purpose. Try benchmarking
grep, you will find that
ag is insurmountable when it comes to performance;
grep may not even be able to run a search if the scope is too large.
ag --help or
man ag for more information.
brew install tree
Lists the contents of directories in a tree-like format.
This one you kind of just have to try for yourself. It's not as crazy of a tool as some of the others, but if you want to see all files within a certain set of directories,
tree does a great job of parsing it into a beautiful, readable format.
More info with
tree --help or
man tree (I'm going to stop referencing these "more infos" now since they are the same for nearly all packages).
brew install cask
Provides a friendly homebrew-style CLI workflow for the administration of Mac applications distributed as binaries.
Okay, this might be the coolest one I have found. This extends
brew past the scope of the terminal and into your GUI applications. For example, you want to install Spotify. Instead of going to your browser to https://www.spotify.com, clicking "Download Spotify", opening the zipped pacakge, etc., all you have to run is
cask install spotify, and boom, it will be downloaded to your computer without any hassle. Not only is this amazing because it takes away having to search for all the apps you want, but it also keeps those apps in one location (opt/homebrew-cask/Caskroom/), making it easier to update, remove, and be aware of what you have installed on your machine.
Obviously this list is just a start, and I am constantly finding new and amazing packages to increase my productivity, but this gives a glimpse as just how amazing and powerful Homebrew is, and why it should be part of every developer's arsenal of tools.
Keep It Clean
With all this awesomeness, it's easy to forget that these tools need to be polished and take care of to perform correctly. I'll make it easy for you with a few aliases I created:
alias brewup='brew update; brew upgrade; brew prune; brew cleanup; brew doctor'
brewup will make it easy to keep homebrew neat. The first two commands I explained earlier. The third command,
brew prune, will remove dead symlinks from the Homebrew prefix. This may sound confusing, and generally isn't needed, but it's never a bad idea to run.
brew cleanup will remove any older versions of packages that you have, keeping things up to date. And last,
brew doctor will check your system for potential problems. If no problems exist, you should see
Your system is ready to brew after the doctor command runs.
Brew It Yourself
Homebrew formulae are simple Ruby scripts. Homebrew's GitHub page is very well documented on how to contribute your own formulae in the rare case that you can't find what you're looking for. Read more on this here