How to properly setup your new Mac
Using a Brewfile
to track installed applications
Since I got my first mac in Mid 2014 I got used to reset it once the next macOS was released. This routine ensures that my MacBook is always running pretty smooth. There was just one problem with this routine:
I had to manually reinstall every program after the hard reset.
The solution: homebrew-file
homebrew-file
is a plugin for the famous dependency manager homebrew
which allows you to track all installed brews in a single Git repository.
How to get started
Before we do anything, let’s make sure we have a time machine backup.
Unless, of course, you got your first Mac 😊
Hard reset
Now we can restart the Mac and hold cmd + r
until the macOS recovery window pops up. After that we can reformat the disc to delete all data with the disc utility app. The only thing left to do is to go back, click on “reinstall macOS” and wait for the os to be downloaded. Depending on your internet connection this can take up to multiple hours, so make sure you’re prepared to wait ☕️
Install the command line tools
Welcome to your fresh installation of macOS 🚀 The first thing to do is to open Terminal and run the following command to install the command line tools: sudo xcode-select --install
Install homebrew & homebrew-file
homebrew-file comes with a handy script which allows us to install both homebrew & homebrew-file itself: curl -fsSL https://raw.github.com/rcmdnk/homebrew-file/install/install.sh |sh
Initialize the Brewfile
Before this step we have to create a Git repository on Github, Gitlab, or anything else. This repo can be public if you like to show of the programs you work with, but it doesn’t have to be.
With brew file set_repo
we can now setup a Brewfile for this repository and with brew file init
we are able to finalize the setup.
Update the Brewfile
After the successful setup we can use hombrew as we are used to do. Usually the first thing I install is git.brew install git && brew file update
… brew file update
updates, as the name suggests, the Brewfile and automatically pushes the changes to the git repo after commiting the changes.
Install applications with brew cask and mas
Well, git is only a command line tool, so you may ask yourself how to add “real” applications like Visual Studio Code. This is as easy as running brew cask install visual-studio-code
Also you may have some applications installed through the Mac App Store. For this purpose a tool called mas
was created. It allows you to search, install and update applications from the Mac App Store right inside your Terminal. It also goes pretty well with homebrew-file. You just have to install mas (brew install mas
) and update your Brewfile.
Thanks to Marcel for pointing out that this section was missing 👍🏻
Recap
Now, once a new macOS version was released, all that’s left to do is:
- Reset the Mac
- Install the command line tools
- Install homebrew and homebrew-file
- Clone the Brewfile with
brew file set_repo
&brew file init
- Install all brews from our Brewfile with
brew file install
- 🚀🎉🕺🏽