How to quickly set up a Mac with Homebrew

When we started our journey to become digital nomads, I was still working on a Mac Mini from 2012, which I upgraded to 16 GB RAM and a 128 GB SSD. Working remotely meant that I had to buy a laptop. I chose the 2016 MacBook Pro without Touch Bar.

Setting up a new Mac always means that you have to spend a few hours configuring the system, installing apps, tweaking the settings and so on. The time wasted setting up a system I’d rather spend doing some work.

To eliminate this time-waster, I searched for a way to automate the setup process.

Choosing the right Apps for your Mac

Working as a digital nomad, you are bound to install a few apps that will make your life easier. Do some research before you get your hands on your new Mac and find apps that help you with your specific tasks. Bear in mind: The Mac ecosystem has a lot of paid apps — many don’t cost much, others do. Even the expensive apps should be given a chance because you usually get exactly what you pay for.

For the better-known apps, you can find reviews and other information on the internet; watch also videos on YouTube where the apps are demonstrated.

The benefits of installing apps with Homebrew & Cask

Choosing apps that are hosted on GitHub will make the setup process a lot easier. The reason: You can use Homebrew and Cask to do the heavy lifting for you.

What is Homebrew? It’s the missing package manager for macOSas it says on its website. Linux lovers will know what I’m talking about. For the Windows guys, I’ll explain how Apps are managed in macOS.

Usually, an app has the extension .app and the only thing you have to do to install it is to drop it into your Applications folder. There are exceptions: Some people create installers for their apps.

The problem with dropping Apps into the Applications folder: It’s not easy to uninstall Apps you don’t want anymore. Apple tells you to just drag the App to the Trash — but it’s not entirely gone; some files remain on your system. Clean freaks like me don’t want ghost files sitting on their system even if they don’t do any harm.

This is where Homebrew comes in: It installs and manages apps in their own directory and symlinks the files into /usr/local.

Let’s get started with Homebrew:

Installing Homebrew

Open Terminal[1] and paste the following into it:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

The script tells you in Terminal what it does, so pay attention.

With Homebrew installed, you can now install things you might need, for example, wget:

brew install wget

One of my favourites is the MPV media player (alternative to VLC):

brew install mpv

You can find a list of all available Homebrew Formulas at brewformulas.org.

The only problem: With Homebrew, you can’t install apps with a GUI — chances are high, that those are the ones you need.

Cask to the rescue

Don’t fret — the solution to your problems is Cask. It’s an extension the Homebrew that helps you speed up macOS applications. No more dragging and dropping!

Install Cask like so:

brew tap caskroom/cask

Now you can install Firefox for example:

brew cask install firefox

It’s that easy. Apps are moved to your Applications folder. You can tell Cask to move them somewhere else if you want to.

Check out the USAGE.md how to use Homebrew-Cask.

Generating a shell script for installation automation

Installing Homebrew and Cask makes your life a lot easier when you want to install all your apps as quickly as possible. But: There is an even quicker method: Writing a shell script and executing it on a new machine.

Automation is quickly becoming a very interesting topic many people are starting to think about. Users of macOS can write a shell script that will install Homebrew, Cask and all the apps they want automatically.

Below you can find my own shell script that installs everything I need. Modify it with the apps you’d like installed on your system:

#!/bin/bash

echo Install Mac App Store apps first.

# Either use mas-cli (https://github.com/argon/mas) or install manually; apps I need: Bear/Simplenote, Tyme, Polarr, Pixelmator, JPEGmini.
read -p "Press any key to continue… " -n1 -s
echo '\n'

# Check that Homebrew is installed and install if not
if test ! $(which brew)
then
echo " Installing Homebrew for you."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" > /tmp/homebrew-install.log
fi

# Update any existing homebrew recipes
brew update

# Upgrade any already installed formulae
brew upgrade --all

# Install my brew packages
brew install wget
brew install mpv

# Install cask
brew tap phinze/homebrew-cask

# Install desired cask packages
brew cask install 1password
brew cask install alfred
brew cask install beamer
brew cask install betterzipql
brew cask install caffeine
brew cask install cakebrew
brew cask install coconutbattery
brew cask install coteditor
brew cask install dropbox
brew cask install flux
brew cask install forklift
brew cask install franz
brew cask install imageoptim
brew cask install kakapo
brew cask install little-snitch
brew cask install marked
brew cask install mpv
brew cask install qlimagesize
brew cask install qlmarkdown
brew cask install tg-pro
brew cask install the-unarchiver
brew cask install transmission
brew cask install viscosity
brew cask install xld

# Remove brew cruft
brew cleanup

# Remove cask cruft
brew cask cleanup

# Link alfred to apps
brew cask alfred link

Don’t forget to make the script excecutable: chmod a+x app-installer.sh

To find which apps are available via Homebrew-Cask, search for them here.

To install brew apps more easily, check out Cakebrew. It’s a nice GUI for Homebrew that will help beginners to search for Formulae, install them and keep them updated.

But what about apps from the Mac App Store?

Yes, I know. Some apps you want to install might not be available with Homebrew and Cask. If you’ve grown attached to Terminal, you should install mas-cli.

As you can see in my shell script, I have quite a few apps that can be installed with Homebrew-Cask — but not all of them.

For the rest, there is no alternative to the Mac App Store. Apps that I have bought or downloaded for free:

  • Tyme — nice time tracking tool
  • Polarr — to spice up images
  • Pixelmator — image retouching
  • JPEGmini — image compression

I did use Noizio for ambient sounds up until now but found the alternative Kakapo.

For the apps I mentioned, you can use mas-cli. Install it with:

brew install mas

It’s basically a simple command line interface for the Mac App Store. Every application in the Mac App Store has a numeric product identifier. Using mas list you can show those numeric identifiers from installed apps. If you want to search for the identifier, use:

mas search app name

You could, of course, integrate mas-cli in your bash script. More information about mas-cli and how to use it here.

Conclusion: Automation rocks

Even though I have automatically installed most of the apps I need, there are still some left that have to be installed manually:

  • Notion — we use it for project planning
  • HORNETDRIVE — secure, encrypted backup solution
  • Canary — email client

Still, I reduced the number of apps that have to be manually downloaded and installed substantially and saved hours of work. Not only that: The shell script you write can be used on other systems or when you want to do a clean install in the future.

[1] Finder→Applications→Utilities→Terminal.app

Article image: Ilya Pavlov | Unsplash

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store