TIL: brew bundle and Homebrew Casks replaced my bespoke scripts

Several years ago I tried to automate my new computer setup so that I could configure a new work laptop or home computer the way I like it easily. It went something like this:

  • Put a list of Homebrew formula in a file.
  • Write a script to loop over those and run brew install for each of them.
  • Keep a list of apps like 1Password, Sublime Text, VS Code. Download and install those.

The last time I revisited my setup, I found that almost everything I wrote could be replaced with built-in stuff (great!).

Homebrew added support for installing a bunch of formulas from a Brewfile by running brew bundle install. You can bootstrap a Brewfile from existing stuff you have installed with brew bundle dump. You can have multiple files–I keep a base Brewfile, and separate ones for work-only and home-only formulas in my dotfiles repo.

Homebrew also added support for Casks, which are packages for pre-compiled artifacts like applications and fonts. Now instead of searching for some program, downloading it, running the installer (or dragging to Applications), unmounting, and trashing the disk image, you can simply run brew install 1password.

Neither of these things are super new! I might even have been able to avoid writing my own bootstrapping scripts in the first place if I was paying attention. Support for bundles was added in 2013. Casks started in 2012 and eventually migrated to the main toolchain in 2016. Over time, Brewfiles have gained support for a ton of other things: casks, installation from the Mac App Store, VS Code extensions, go tools, python tools, and more.

My current Brewfile looks like this (edited for length):

# Core formula
brew "fzf"
brew "gh"
brew "git"
brew "jq"
brew "ripgrep"
...

# Apps
cask "1password"
cask "google-chrome"
cask "rectangle"
cask "sublime-text"
cask "visual-studio-code"
...

# Apps from the Mac App Store
mas "Pixelmator Pro", id: 1289583905
...

# VS Code extensions
vscode "braver.vscode-solarized"
vscode "golang.go"
vscode "shopify.ruby-lsp"
...

I deleted a bunch of code from my bootstrapping process. Now when I want to download and install an app, I start with brew search [name] and install via Homebrew so I can track install, uninstall more easily.