Automatically install (almost) anything in your Mac with Homebrew

Recently I decided to do a clean install in my personal Mac at the same time, start optimizing my dev setup and overall productivity. The first step towards this goal was to automate installing all my packages and apps that I use on a daily basis.

After “researching” for a bit I found that with Hombrew you can define all the packages that you would like to get installed in a Brewfile and then just run brew bundle and it will install everything. I have been using Brew for many years now but this was news to me and it was a breeze.

1. Install Homebrew

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

I have my Brewfile in dotfiles repo in Github and in a follow up post I will be covering how I automate this process and also start building other dotfiles to ease my life as a developer.

2. Create a Brewfile

Then, create the Brewfile using your editor of choice or if it’s a Clean Installed Mac you can use TextEdit or Vim.

cd && vim Brewfile

In this file you will need to add all the dependencies that you will like to be installed in your Mac;

tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-versions"
tap "homebrew/core"
tap "homebrew/services"

cask_args appdir: '/Applications'
cask "visual-studio-code"
cask "spotify"
cask "slack"
cask "1password"
cask "notion"
cask "zoom"
cask "google-chrome"
cask "ngrok"
brew "docker"
brew "nvm"
brew "yarn"
brew "awscli"
brew "python3"
brew "mongodb-community"
brew "apache-spark"

You can search specific packages here.

And you can also do brew bundle dump to get all your dependencies from your current computer to a brewfile that then you can use on any other Mac.

3. Lets run it!

Finally, execute brew install from Terminal and you should be good to go. It will take some time depending on how many dependencies have in your Brewfile.