Christoph Nakazawa

Set up a new Mac, Fast

I just received a new Starlight M2 MacBook Air and I wanted to share scripts, apps, protips, and what hasn’t worked for me in the past when setting up a new Mac, fast.

Over the years I used many different personal and work Macs. While there are various methods to automatically migrate data like Apple’s Migration Assistant, they are usually imperfect, require a lot of manual work, and often cannot be used on corporate Macs. I prefer setting up new devices from scratch as it keeps my computers clean. It also forces me to make my setup portable which prevents the potential for data loss.

To get started setting up a new Mac, open your Terminal and run xcode-select --install and sudo xcodebuild -license in your terminal.1

Dotfiles

The first step is to log in to GitHub and set up a new SSH key via GitHub → SettingsSSH and GPG KeysNew SSH key. Most likely you’ll find yourself reading the Connecting to GitHub with SSH guide for the 100th time because you just cannot remember how to set up a new SSH key otherwise.

Once you are ready to use git locally, clone your dotfiles repository into ~/.home via git clone git@github.com:<username>/dotfiles.git .home. If you don’t have your own dotfiles repo yet, I highly recommend making one to backup your bash, fish shell, git, and other configuration. Check out all of these examples, or clone a copy of my dotfiles repo cpojer/dotfiles.

My dotfiles repo has a convenient ./bootstrap script from Zach Holman’s dotfiles repo. This script links every file ending in .symlink into your user’s root directory. I like this method as it keeps your dotfiles repository organized and easy to manage, yet it makes all your configuration available in the right places.

Package Manager: Homebrew

The next step is to install Homebrew with all binaries, apps and fonts2 to get your Mac ready for development. On your existing Mac, run brew bundle dump and then copy the resulting Brewfile to your new Mac. Here is an example Brewfile and a homebrew install script:

Brewfile

tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-fonts"
tap "homebrew/core"
tap "homebrew/services"
brew "bat"
brew "diffutils"
brew "exa"
brew "fd"
brew "ffmpeg"
brew "fish"
brew "fzf"
brew "gh"
brew "gifsicle"
brew "git"
brew "git-delta"
brew "grep"
brew "jq"
brew "node"
brew "pnpm"
brew "postgresql", restart_service: true
brew "ripgrep"
brew "wget"
brew "yarn"
brew "youtube-dl"
cask "1password"
cask "airflow"
cask "alfred"
cask "discord"
cask "disk-inventory-x"
cask "dropbox"
cask "firefox"
cask "font-fira-code"
cask "font-fira-code-nerd-font"
cask "imageoptim"
cask "iterm2"
cask "obs"
cask "protonvpn"
cask "rectangle-pro"
cask "slack"
cask "sublime-text"
cask "syncalicious"
cask "transmit"
cask "visual-studio-code"
cask "vlc"
cask "whatsapp"
cask "zoom"

homebrew.sh

bash
#!/usr/bin/env bash
if test ! $(which brew); then
echo "Installing homebrew..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
brew update
brew bundle

Once done, open each app one by one to tell mac OS that you are happy to run dangerous Internet software, and log in to the ones that require logging in.

If you don’t want to use Homebrew casks, the best alternative I’ve found is to create a My Apps folder within your Dropbox folder and to put every app directly in there instead of your /Applications folder. Apps will be kept up-to-date across all your machines and you won’t have to manually redownload them one by one when you set up a new Mac. I have used this approach for years and it worked well. I only switched to Homebrew casks because it’s even simpler.


You’ll have all the subsequent apps installed on your Mac after running the above script.

Apps

Backup: Dropbox

I have used Dropbox on my Mac since 2009 and prefer it over other solutions. While you might prefer alternative clients, Dropbox does its job well. It keeps files local instead of using the “network drives” feature and most importantly, it doesn’t get in the way.

I keep all of my code inside of my Dropbox folder. Have you ever accidentally reverted a day’s worth of work with a git checkout . or deleted a file you shouldn’t have? Such moments are painful. Keeping code in Dropbox prevents such accidents from happening, and makes your code portable across devices without having to rely on git alone.

Protip: “.dropboxignore”

If you are working on frontend projects, you most likely have several large node_modules or build output folders. It’s annoying to keep syncing those to Dropbox, both for the network and CPU overhead, but thankfully Dropbox has a way to ignore files from syncing. Because it’s a hassle to manually deal with file attributes I recommend using .dropboxignore which can automate managing these flags for you:

bash
sudo sh -c "$(curl -fsSL https://raw.githubusercontent.com/sp1thas/dropboxignore/master/utils/install.sh)" c

After installing .dropboxignore, you can run dropboxignore genupi . in the desired folders to ignore files based on existing .gitignore files. This massively reduces the amount of time Dropbox spends syncing stuff.

Note: I am a big fan of Google Photos and have been paying for photo storage for years. For a few months in 2021, I attempted to use Google Drive in the interest of cutting my cloud subscription costs but it was slow, unstable and did not allow me to keep local copies of my files after the app was completely changed from under me one day to "Google Backup & Sync on Mac". I'm not a fan.

Syncing Settings: Syncalicious

Syncalicious. If you have been copying my Homebrew install script, you’ll now have Syncalicious installed already. With Syncalicious you can backup the preferences for any of your apps. This is a great way to avoid having to keep two computers side-by-side and going through the setting screen of each app to mirror your setup exactly the way you like it. However, keep in mind that Syncalicious is still alpha software, and Mackup might be a better fit for you.

Syncalicious Screenshot

Right now, Syncalicious keeps preferences on a per-machine basis and you’ll manually have to locate your synced preferences in your Dropbox folder and copy them to ~/Library/Preferences. However, after this (and a restart) my new Mac is usually ready to go with the same setup as my previous one!


The rest of this blog post is focused on apps and protips:

Window Management: Rectangle Pro

Rectangle Pro. I tried many window management apps in the past and didn’t like most of them. Some have obscure keyboard shortcuts or feel slow. A long time ago, I discovered “Zooom2” which had two great features:

  • Moving and resizing windows using a keyboard shortcut together with the touchpad/mouse.
  • Snapping and resizing windows when dragging them to the edge of the screen.

Unfortunately, Zooom2 was frequently broken by major macOS updates and has been discontinued. I used BetterTouchTool for a few years to replicate the same behavior. However, I found it to be overly complex, it crashed frequently, and I wasn’t using most of its features, all the while it kept asking me to pay for upgrades frequently. macOS has since added a gesture to drag windows using the cursor and ⌃ control + ⌘ command that can be enabled by running defaults write -g NSWindowShouldDragOnGesture -bool true, but it does not offer a gesture for resizing.

Enter Rectangle (Pro). The free version itself won my heart quickly, but the Rectangle Pro version is 💯% worth it. Not only does it support the ability to drag and resize windows using a keyboard shortcut and the cursor it also has a convenient feature to “throw” windows into various directions to maximize or arrange them. Check out how “throwing” windows with the cursor and ⌃ control + ⌘ command works:

Spotlight Replacement: Alfred

Alfred. I have only recently started using Alfred again because I wanted a fuzzy file-search feature (in Finder) that feels native to macOS which Alfred implements using the ' prefix. I didn’t like the idea of using Spotlight and Alfred side-by-side, but you can overwrite the keyboard shortcut for Spotlight by disabling Spotlight in System PreferencesKeyboardShortcutsSpotlight. Then you can map command ⌘ + space to Alfred in the Alfred settings. Excellent!

Alfred Screenshot

A lot of people are using Raycast, which is another good choice but it feels slower than Alfred.

Casting to TV: Airflow

Airflow. I’ve tried various apps to cast to an AirPlay-compatible TV, and Airflow has always worked the best for me.3

Airflow Screenshot

Pack/unpack archives: Archiver

Archiver. I have always loved this app made in 🇦🇹 Austria for extracting archives. It has a beautiful and simple user interface/experience.

Archiver Screenshot

Filesystem Analysis: Disk Inventory X

Disk Inventory X. It’s an older app, but it checks out! A free app that makes it easy to visualize what’s taking up space on your Mac. Especially useful if you have a small hard drive.

Disk Inventory X Screenshot

To open this app for the first time you most likely have to navigate to /Applications, ⌘ command + right click and tap Open to bypass the security dialog because the app isn’t signed properly.

VPN: ProtonVPN

ProtonVPN. If you need a VPN, I’ve found ProtonVPN to be a great choice. I love their “Quick Connect” feature which you can use to map a specific type of VPN connection to a single press of a button.

ProtonVPN Screenshot

I’m currently evaluating ProtonMail, and am hoping that Proton will release a desktop application for Proton Drive in the future.

Password Manager: 1Password

I’m honestly conflicted about suggesting 1Password. My advice is to use any password manager and not to use the same password for any two services! I’ve always been a happy customer of 1Password but the recent switch to a subscription-based model and breaking 1Password 6 for M1/M2 users has left a sour taste in my mouth.4. I might switch to a different app one day.

Protips

Text replacements

How often have you typed your email address on your phone or your Mac? Or your credit card number? In System PreferencesKeyboardText you can define custom text replacements that work system-wide.

Keyboard Shortcuts Screenshot

I usually map @@ to my email address and @card to my credit card number. I also like auto-replacing certain characters like -> to :

German Keyboard Layouts and option+space

If you are using a German or other European keyboard layouts, you are likely using the ⌥ option-key to type symbols while programming. If you are typing quickly, you might end up accidentally hitting ⌥ option and space together which inserts a non-breaking space. Nowadays VS Code will highlight such characters (and when using JavaScript, prettier will automatically remove them), but it can still be annoying.

You can avoid this by creating a file ~/Library/KeyBindings/DefaultKeyBinding.dict and dropping this into it:

{
"~ " = ("insertText:", " ");
}

Tap every “Tip”-Notification at least once.

When you set up a new Mac or iPhone, the “Tips” app will continuously nag you to learn more about your new Mac. Other apps might notify you to try out new features, and sometimes these things tend to get more aggressive when you ignore them. I have found that quickly jumping into any tutorial and hitting the “Next” button until the end is a good way to get rid of these sorts of notifications.

Remove status bar icons.

If you can’t figure out how to get rid of a specific status bar icon, you can use ⌘ command + drag&drop to get rid of them:


I drafted this blog post on my old laptop while I set up the new one. It took me about two hours until I could seamlessly transition from working on my blog inside of VS Code from one laptop to the other. The above install scripts, given a fast Internet connection, should take no more than 15 minutes to run. Most of the actual time spent was the sort of speed-run you do when you have to log into all the apps, services and websites.

Check out the second part of this post: Setting up the Perfect Development Environment.

Footnotes

  1. Xcode install was slow. At one point it told me it would take 53 hours 😅

  2. Yes! Homebrew does fonts these days!

  3. Short of just plugging my MacBook directly into the TV.

  4. And while I genuinely don’t mind Electron apps and appreciate what they have done for desktop, 1Password 8 has significantly regressed performance in almost every key interaction 😟

Tweet about this article, or share it with your friends. Thank you for reading, and have a great day!

Ready for Another Post?

Subscribe for More