← Back to Blog

Preparing for a fresh macOS installation with Homebrew

4 min read
macOS

Preparing for a fresh macOS installation with Homebrew

Recently, I had the fun task of setting up my Mac from scratch… twice. The first time, my Mac died after a macOS update and the second time because I got a new computer from work. In both cases, I decided not to use a Time Machine Backup, so I had to manually install apps to make my computer feel familiar. This endeavour takes a lot of time, mostly spent looking for installers and waiting for downloads/installs and, sometimes waiting for expanding compressed files (I’m looking at you, Xcode). Things usually don’t end here, sometimes I don’t remember ALL the apps I need to install and it’s a bit annoying to realise what’s missing when you are mid-work and something’s not there.

To improve this, I decided to look for a good way to automate this process and chose Homebrew’s Bundle for this.

Bundle

When we write software, we usually manage our dependencies using package managers (e.g. SPM, Cocoapods) but when it comes to software in our OS it is common to do this manually and we need to install stuff from multiple sources. Bundle comes to the rescue.

Preparation

Before wiping our computers clean, we need to “backup” our current state and prepare a list of apps to install.

We’ll start by setting up Homebrew, entering this command in a Terminal window:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Next, we’ll create a Brewfile file by running the dump command to have a list of all software currently installed in our computer

brew bundle dump

If we open the file created by dump, we’ll find a list of apps installed on our computer. This is limited to apps installed using Homebrew and, from the Mac App Store.

In this file, we usually find the following commands:

  • tap a Git repository of Formulae and/or commands
  • brew regular Homebrew command-line apps
  • mas Mac App Store apps
  • cask apps distributed as binaries

Now it’s time to clean up this file a bit, add some comments to divide it into sections, and add missing apps that were not found by dump.

Here’s the “cleaned up” version I use:

cask_args appdir: "/Applications"

tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/core"
tap "homebrew/cask-fonts"
tap "homebrew/cask-drivers"

# Mac App Store apps
brew "mas"

mas "1Password", id: 1333542190
mas "Numbers", id: 409203825
mas "Pages", id: 409201541
mas "Keynote", id: 409183694

mas "Ulysses", id: 1225570693
mas "Pixelmator Pro", id: 1289583905
mas "Magnet", id: 441258766
mas "The Unarchiver", id: 425424353
mas "GarageBand", id: 682658836
mas "Mactracker", id: 430255202
mas "Whatsapp", id: 1147396723
mas "Slack", id: 803453959
mas "Spark", id: 1176895641
mas "TinyStopwatch", id: 1447754003
mas "DaVinci Resolve", id: 571213070

# Development
#mas "Xcode", id: 497799835
mas "Developer", id: 640199958
mas "RocketSim", id: 1504940162
mas "Sequel Ace", id: 1518036000

brew "carthage"
brew "fastlane", link: false
brew "git-lfs"
brew "sourcery"
brew "swiftlint"
brew "node"
brew "mysql"
brew "ffmpeg"
brew "cocoapods"
brew "swiftformat"

cask "visual-studio-code"
cask "tower"
cask "dash"
cask "postman"
cask "mysqlworkbench"
cask "proxyman"
cask "font-jetbrains-mono"

# Utilities
cask "iterm2"
cask "alfred"
cask "expressvpn"
cask "grandperspective"
cask "vlc"
cask "istat-menus"
cask "forecast"
cask "keycastr"
cask "transmission"
cask "karabiner-elements"
cask "xcodes"
cask "teamviewer"

# Communications
cask "skype"
cask "google-chrome"
cask "zoom"
cask "discord"

# - Gadgets
cask "obs"
cask "elgato-stream-deck"
cask "logitech-g-hub"
cask "philips-hue-sync"

# - Other
cask "raspberry-pi-imager"
cask "ultimaker-cura"

You’ll notice I excluded Xcode in this list, we’ll address that in a follow up post. This is the file Bundlewill use to know what to install on the new computer/OS

Apps Installation

On the new Mac (or after wiping the OS clean), we start by installing Homebrew entering this command in a Terminal window:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Then, we just need to run

brew bundle

And voila! Homebrew will install everything we defined on the Brewfile file. Now we can use the time it takes to install all the apps from the list in something more productive/fun.

Summary

In this article we saw how to use Bundle as some sort of dependency manager for apps on macOS, making it easier to configure a new system when we need to.