Skip to content

Automate installing apps and utilities with Homebrew bundle

Published:

2 min read

If you periodically set up your Macbook from scratch like I do, you’re probably frustrated by the manual setup process.

Homebrew to the rescue. It’s a macOS package manager that I’ve used since I started using macOS. It allows creating a “bundle” file that can automate the process of installing many command-line utilities, applications, and apps from the App Store.

Create a bundle file

In my dotfiles repository, I’ve created a brewfile.sh, which contains the following list:

# Specify directory to install
cask_args appdir: "/Applications"

# Install packages
tap 'homebrew/bundle'
brew 'mas'
brew 'direnv'
brew 'git'
brew 'git-crypt'
brew 'git-lfs'
brew 'readline'
brew 'scrcpy'
brew 'yarn'
brew 'watchman'
brew 'vale'
brew 'cocoapods'
brew 'typos-cli'

# Images, Video
brew 'ffmpeg'

# Fonts
cask 'font-jetbrains-mono'
cask 'font-hack-nerd-font'

# Other apps
cask 'insomnia'
cask 'visual-studio-code'
cask 'google-chrome'
cask 'google-chrome@canary'
cask 'brave-browser'
cask 'arc'
cask 'imageoptim'
cask 'expo-orbit'

## App Store apps
mas "1Password 7", id: 1333542190
mas "Slack", id: 803453959
mas 'Bandwidth+', id: 490461369

When I am setting up my Macbook, I download this file and run the following command to install everything from this file:

brew bundle --file=brewfile.sh

Dissection of the bundle file

The important piece from the above configuration is to define a path for the applications to install inside the Applications directory. Otherwise, macOS might recognize an app or warn you to manually move it inside that directory. The cask_args allows passing the directory path.

cask_args appdir: "/Applications"

Then, adding third-party repos from Homebrew allows installing packages from external sources.

tap 'homebrew/bundle'
tap "homebrew/core"

The next step is to install packages and other applications that I’d be installing manually otherwise.

Also, I discovered that mas is a command line interface for macOS App Store and allows an app from the store with its product identifier and can be used with brew. For example:

mas 'Bandwidth+', id: 490461369

Searching an app’s product identifier is easy and requires searching the app using mas search app-name. For example:

mas search 1Password
  1333542190  1Password 7 - Password Manager                  (7.9.11)

I like this way of installing necessary stuff when I set it up from scratch.


Previous Post
Adding Bluesky icon to my Astro blog
Next Post
Tag gardening

I'm a software developer and technical writer. On this blog, I share my learnings about both fields. Recently, I have begun exploring other topics, so don't be surprised if you find something new here.

Currently, working as a documentation lead at Expo.