The purpose of this guide is to document how to manage your Mac like a boss. After much trial and error I believe this is the fastest, most efficient method to set up a clean, organized, and up-to-date development environment for a Mac.
The overview is presented here, and the details are maintained in the wiki
I’m a polygot fullstack developer so I have a fairly complex setup. Our goals here are:
There are three very important repositories that contain all configuration data. I would like to explain the purpose of each.
.dotfiles - is not actually what it sounds like. My dotfiles are actually managed by mackup. Mackup is a community-driven tool for backing up and restoring dotfiles and application settings. This repo is called dotfiles because that was it’s origin and now mainly because Strap installs it automatically (and runs /script/setup
automatically, which we leverage to install everything Homebrew can’t) along with the “homebrew-brewfile” repo below.
.macos - This repository contains the settings for the MacOS operating system (and some applications and utilities). The origin comes from Mathias Bynens’ amazing MacOS configuration script.
These repos contain all of my configuration.
A lot of stuff. Seriously, a lot of stuff. Poke around in the Wiki
We want to use the best tools out there - e.g. the ones with the most community support and momentum and the best functionality.
Bootstrap Your System
Shell: Zsh. Zsh is awesome, really. To use Zsh like a boss we will install .oh-my-zsh. It autoupdates, has great plugins and a very active community behind it. Your ZSH settings will be backed up by Mackup below. Resources:
Terminal: iTerm2 for our terminal program. iTerm2 is free and it rocks. Your settings will be backed up by Mackup. Lately I have also been using Hyper and it’s growing on me.
Resources:
Editor: Visual Studio Code as our code editor. VSCcode replaced Atom as my main editor.
Tool Version Management: n. Manage Node versions:
Package Management: Homebrew, npm/yarn, pip. Homebrew is a community-driven package installer and an essential tool for every hacker’s toolkit. Homebrew automates the setup, compiling and linking of binaries. It also makes updating and uninstalling binaries a breeze. It will be automatically installed by Strap above. Resources:
Dotfiles Management and Backup: Mackup. Backing up and Restoring our .dotfiles (our configuration) with mackup. Mackup is a community-driven tool for backing up and restoring system and application settings. See dotfiles section below.
If you run into any issues, please open an issue on this repository and I’d love to get it fixed. Or, pull requests are always appreciated.
===
I want a clean, repeatable process to setup a MacOS machine, and keep multiple MacOS machines similarly configured.
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 is update macOS to get the latest security updates and patches.
MacOS now comes with zsh as the default shell. Install Oh My Zsh for sensible defaults.
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Install the Homebrew package manager. This will allow you to install almost any app from the command line.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Make sure everything is up to date.
brew update && brew doctor
Install a few things manually to get bootstrapped:
brew install mackup gum fnm
Program | Purpose |
---|---|
mackup | .dotfiles Management |
gum | Fancy Scripts |
fnm | Fast Node Manager |
gh | GitHub CLI |
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:
gh auth login
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.
sh -c "$(curl -fsSL https://raw.githubusercontent.com/dstroot/macos-setup/master/scripts/install.sh)"
dot
script)All my Homebrew apps are maintained in a .Brewfile
. Running the maintenance script dot
will install them and keep them updated.
dot
Generate an SSH key to distribute:
ssh-keygen -t ed25519 -C "dan.stroot@gmail.com"
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.
eval "$(ssh-agent -s)"
Add key.
ssh-add --apple-use-keychain ~/.ssh/id_ed25519
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
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.
ssh myssh
Here are the things I always change.
To get the Home folder in the finder, press CMD + SHIFT + H and drag the home folder to the sidebar.
Make Google Chrome default browser
Automatically hide and show Dock Show indicators for open applications
Key Repeat -> Fast Delay Until Repeat -> Short Disable “Correct spelling automatically” Disable “Capitalize words automatically” Disable “Add period with double-space” Disable “Use smart quotes and dashes”
Allow apps downloaded from App Store and identified developers Turn FileVault On (makes sure SSD is securely encrypted)
Change computer name Make sure all file sharing is disabled
Add “Rectangle” to Login items
A few more commands to change some defaults.
# 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
Press CMD + SHIFT + P and click “Install code command in PATH”.
Now you can use code {file} to open any file in VSCode.
View Dotfiles for keyboard shortcuts and settings
CMD + SHIFT + '
(prevents messing with other commands)CMD + OPTION + LEFT
CMD + OPTION + RIGHT
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
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.