Dan Stroot

Set up a Mac for Development

A clean, repeatable, process to setup a MacOS machine and keep multiple MacOS machines similarly configured

Date:


I want a clean, repeatable process to setup a MacOS machine, and keep multiple MacOS machines similarly configured.

Getting Started

The setup assistant will launch once you turn the computer on. Enter your language, time zone, Apple ID, and so on. The first thing you should do once you get in is to update macOS to get the latest security updates and patches. Once ready follow the steps below.

1

Setup Oh-My-ZSH

1. Setup Oh-My-ZSH

MacOS now comes with zsh as the default shell. Install Oh My Zsh for sensible defaults.

...title, and
(bash)
sh -c "$(curl -fsSL \
https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
...caption

2. Install Homebrew

Install the Homebrew package manager. This will allow you to install almost any app from the command line.

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

Make sure everything is up to date.

just...title
(bash)
brew update && brew doctor

3. Authenticate to GitHub

Authenticate to GitHub so you can clone your private repos (e.g. your private .dotfiles repo). Go through the login process and accept the defaults:

(bash)
brew install gh && gh auth login

4. Run Bootstrap Script

I maintain a bootstrap script in my macos-setup/scripts repository to setup a new machine. It will clone my .dotfiles and .macos settings repos and restore my dotfiles using mackup. It is idempotent.

filename ...title
(bash)
sh -c "$(curl -fsSL \
https://raw.githubusercontent.com/dstroot/macos-setup/master/scripts/install.sh)"

5. Manual Stuff

After running the bootstrap script there are still some manual steps to complete:

  • Open VSCode and turn on settings sync, using GitHub, override local settings (use the settings backed up in the cloud).
  • Open iTerm2 and load settings from ~/.dotfiles/iterm2
  • Open up Hey email app and sign in.
  • Open a Microsoft document and sign in (use Outlook.com credentials).
  • Open Chrome and login and setup sync.
  • Setup Safari and make sure your extensions are setup.
  • Check .dotfiles/pnpm to see what global things need to be installed
  • Install Samsung Magician

6. Setup SSH

First, generate an SSH key. It is widely recommended (also by Github) that you use ed25519 encryption for your SSH keys. Here is the command to do so. Your new SSH key pair will be saved in the default location (/.ssh) with the default name (id_ed25519):

(bash)
ssh-keygen -t ed25519 -C "your_email@example.com"
  • replace your_email@example.com with your email (for GitHub use your Github account email)
  • -C flag sets a comment or label for identifying your SSH key, and using your email as the comment is a common practice
  • -t ed25519 sets the encryption algorithm for your SSH key to ed25519

When you get the following prompt: >Enter passphrase (empty for no passphrase): Just press enter to generate the SSH key without a passphrase. Or, enter a passphrase for an added layer of security.

Next, setup SSH agent. SSH agent is part of OpenSSH and is a key manager for SSH. It holds your keys and certificates in memory, unencrypted, and ready for use by ssh. It saves you from typing a passphrase every time you connect to a server. It runs in the background on your system, separately from ssh, and it usually starts up the first time you run ssh after a reboot.

(bash)
eval "$(ssh-agent -s)"

Now add your SSH private key to the ssh-agent:

(bash)
ssh-add --apple-use-keychain ~/.ssh/id_ed25519

--apple-use-keychain flag is Apple’s standard version of ssh-add . This adds the passphrase of your SSH key automatically to the keychain so that you don’t have to enter the passphrase every time you make an SSH connection. If you have not set a passphrase for your key, you can omit the --apple-use-keychain flag

SSH Config

Simplify the process of ssh'ing into other boxes with your SSH config file. Create ~/.ssh/config if it does not already exist.

Add the following contents, changing the variables for any hosts that you connect to. Using the below will be the same as running ssh -i ~/.ssh/key.pem user@example.com.

~/.ssh/config

(bash)
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_ed25519
 
Host myssh
HostName example.com
User user
IdentityFile ~/.ssh/key.pem

Now just run the alias to connect.

(bash)
ssh myssh

Here are specific instructions for GitHub - but note they are unnecessary since you already used gh above to authorize GitHub.

7. Set MacOS Settings

These are ordered just like the System Settings app (by vertical order):

1. WiFi

  • No changes (should be already setup)

2. Bluetooth

  • No changes

3. Network

  • No changes

4. Energy

  • Options: Disable Slightly dim the display on battery
  • Options: Wake for Network Access: Never (off=0, on=1)

5. General

  • Software Update:Updates click "i with circle" ⌽ and turn everything on.
  • Login Items & Extensions:
    • Review "Open at Login", "Allow in Background", and "Extensions"
    • Extensions: Click "i with circle" ⌽ for "sharing" and adjust

6. Accessibility

  • Enable reduce motion

7. Appearance

  • No changes

8. Apple Intelligence and Siri

  • Listen for: Off

9. Control Center

  • No Changes

10. Desktop & Dock

  • Enable Automatically hide and show Dock
  • Disable opening animations
  • Disable Show suggested and recent apps in the dock
  • Minimize windows using: Scale Effect
  • Enable Minimize windows into application icon
  • Click wallpaper to reveal desktop: Only in Stage Manager
  • Enable Show indicators for open applications
  • Enable Mission Control: Group windows by application
  • Disable Mission Control: Drag windows to top of screen to enter Mission Control
  • Default Web Browser: Google Chrome

11. Displays

  • Disable Automatically adjust brightness
  • Night Shift:Schedule: Sunset to Sunrise

12. Screen Saver

  • No changes

13. Spotlight

  • Search Results, turn all off except:
    • Applications
    • Documents
    • Folders
  • Disable Help Apple Improve Search

14. Wallpaper

  • No changes

15. Notifications

  • Disable Allow Notifications from iPhone
  • Disable Allow notifications when screen is locked

16. Sound

  • No changes

17. Focus

  • No changes

18. Screen Time

  • No changes

19. Lock Screen

  • Enable Show message when locked: "Found this computer? Please contact Dan Stroot at dan.stroot@gmail.com or (949) 463-4044. Reward!"

20. Privacy & Security

  • Enable FileVault (should be on by default)

21. Touch ID & Password

  • Enable Apple Watch
  • Enroll additional fingers:
    • Both index fingers at minimum

22. Users & Groups

  • No changes

23. Internet Accounts

  • Add Google

24. Game Center

  • No changes

25. iCloud

  • Enable Advanced Data Protection
  • Click "See All" and make sure everything is enabled

26. Wallet & Apple Pay

  • No changes (should have been setup during initial setup process)

27. Keyboard

  • Key Repeat -> Fast
  • Delay Until Repeat -> Short
  • Press fn key to: Show Emoji & Symbols

These may not be needed anymore: Text Input: Click "Edit":

  • Disable "Correct spelling automatically"
  • Disable "Capitalize words automatically"
  • Disable "Add period with double-space"
  • Disable "Use smart quotes and dashes"

28. Mouse

  • Increase tracking speed

29. Trackpad

  • Enable "Tap to click"
  • Secondary click: "Click or Tap With Two Fingers"
  • Increase Tracking speed

30. Printers & Scanners

  • Add local printer: HP LaserJet M110w

8. Application Settings

App: Finder

General:

New finder windows show my home folder: "Dan"

Enable Sync Desktop & Documents Folders

Tags:

  • Disable Tags (uncheck, or delete existing tags)

Sidebar:

  • Adjust favorites and enable home folder

Advanced:

Disable Show warning before removing from iCloud drive Disable Show warning before emptying the Bin

(bash)
defaults write "com.apple.finder" "WarnOnEmptyTrash" '0'

Enable Remove items from the Trash after 30 days

(bash)
defaults write "com.apple.finder" "FXRemoveOldTrashItems" '1'

When performing search: Search the Current Folder

(bash)
defaults write "com.apple.finder" "FXDefaultSearchScope" 'SCcf'

Toolbar:

  • Right click and add airdrop and new folder, remove tabs

View:

  • Show Path Bar

    (bash)
    defaults write "com.apple.finder" "ShowPathbar" '1'
  • Show status bar

    (bash)
    defaults write "com.apple.finder" "ShowStatusBar" '1'

More finder settings:

deep.js
(bash)
# Show Library folder
chflags nohidden ~/Library
 
# Show hidden files
defaults write com.apple.finder AppleShowAllFiles YES
 
# Show path bar
defaults write com.apple.finder ShowPathbar -bool true
 
# Show status bar
defaults write com.apple.finder ShowStatusBar -bool true
 
# Prevent left and right swipe through history in Chrome
defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool false

App: Safari

  • View: show favorites bar
  • settings:general: Disable Open safe files after downloading

Chrome

  • Install uBlock Origin
  • Install React DevTools
  • Install Redux DevTools
  • Install Duplicate Tab Shortcut
  • Settings -> Set theme to "Dark"

Visual Studio Code

Press CMD + SHIFT + P and click "Install code command in PATH".

View Dotfiles for keyboard shortcuts and settings

Extensions

  • Install New Moon Theme
  • Install GitLens
  • Install Highlight Matching Tag
  • Install ESLint
  • Install Prettier
  • Install Jest
  • Install Jest Runner

Rectangle

  • Full Screen: CMD + SHIFT + ' (prevents messing with other commands)
  • Left Half: CMD + OPTION + LEFT
  • Right Half: CMD + OPTION + RIGHT

iTerm2

For some reason, iTerm2 does not let you use ⌥ + ← and → to tab through words in the terminal by default. I found this article to fix it: Use ⌥← and ⌥→ to jump forwards / backwards

  • Go to Profiles -> Keys:
    • Change ⌥← via "Send Escape Sequence" with b
    • Change ⌥→ via "Send Escape Sequence" with f

Conclusion

That sums it up for my current preferences on setting up a MacBook Pro. I hope it helped speed up your process or gave you ideas for the next time you're setting one up.

(html)
<figure data-rehype-pretty-code-figure="">
  <figcaption
    data-rehype-pretty-code-title=""
    data-language="bash"
    data-theme="one-dark-pro"
  >
    settings.sh
  </figcaption>
  <pre
    tabindex="0"
    data-language="bash"
    data-theme="one-dark-pro"
    __rawstring__='sh -c "$(curl -fsSL \
    https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"'
  >
    <code data-language="bash" data-theme="one-dark-pro" style="display: grid;">
      <span data-line="">
        <span style="color: rgb(97, 175, 239);">sh</span>
        <span style="color: rgb(209, 154, 102);"> -c</span>
        <span style="color: rgb(152, 195, 121);"> "$(</span>
        <span style="color: rgb(97, 175, 239);">curl</span>
        <span style="color: rgb(209, 154, 102);"> -fsSL</span>
        <span style="color: rgb(86, 182, 194);"> \</span>
      </span>
      <span data-line="">
        <span style="color: rgb(152, 195, 121);">
          https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
        </span>
      </span>
    </code>
  </pre>
</figure>
(html)
<figure data-rehype-pretty-code-figure="">
  <div
    data-rehype-pretty-code-title=""
    data-language="bash"
    data-theme="one-dark-pro"
  >
    settings.sh
  </div>
  <div
    class="relative flex flex-col space-y-2 rounded-lg bg-gray-200 p-4 dark:bg-gray-700"
  >
    <div class="flex items-center space-x-2">
      <span class="h-3 w-3 rounded-full bg-[#ff605c]"></span>
      <span class="h-3 w-3 rounded-full bg-[#ffbd44]"></span>
      <span class="h-3 w-3 rounded-full bg-[#00ca4e]"></span>
      <span class="text-sm">Language: bash</span>
    </div>
    <div class="not-prose rounded bg-gray-800 dark:bg-black">
      <pre
        class="m-3 overflow-auto text-nowrap text-sm font-medium"
        tabindex="0"
        data-language="bash"
        data-theme="one-dark-pro"
      >
        <button
          class="absolute right-1 top-1 inline-flex h-8 w-8 items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-gray-100 hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 hover:dark:bg-gray-800"
          aria-label="Copy to clipboard"
        >
          <span class="sr-only">Copy</span>
          <svg
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
            class="h-4 w-4"
          >
            <rect width="14" height="14" x="8" y="8" rx="2" ry="2"></rect>
            <path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"></path>
          </svg>
        </button>
        <code
          class="text-pretty"
          data-language="bash"
          data-theme="one-dark-pro"
          style="display:grid"
        >
          <span data-line="">
            <span style="color:#61AFEF">sh</span>
            <span style="color:#D19A66"> -c</span>
            <span style="color:#98C379"> "$(</span>
            <span style="color:#61AFEF">curl</span>
            <span style="color:#D19A66"> -fsSL</span>
            <span style="color:#56B6C2"> \</span>
          </span>
          <span data-line="">
            <span style="color:#98C379">
              https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
            </span>
          </span>
        </code>
      </pre>
    </div>
  </div>
  <figcaption
    data-rehype-pretty-code-caption=""
    data-language="bash"
    data-theme="one-dark-pro"
  >
    ...caption
  </figcaption>
</figure>

Sharing is Caring

Edit this page