These are my configuration files and notes for setting up a new Mac.
Do the following, in this order:
- Clone this repo
- Install
oh-my-zsh
- Install Rosetta 2 (for M1 Macs)
- Install Homebrew and packages
- Set computer name
- Set up 1Password
- Sign into iCloud
- Sign into Fastmail
- Install Mac App Store apps
- Restore Mackup
- Set up SSH
- Set up Node
Run git once so macOS will try to install command line tools:
git
Make directory and clone
mkdir ~/Code && git clone https://github.com/expandrew/dotfiles ~/Code/dotfiles
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
sudo softwareupdate --install-rosetta
Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Get brew
in the PATH for now (this gets resolved for real when Mackup restores my .zshrc below)
eval "$(/opt/homebrew/bin/brew shellenv)"
Install everything from Brewfile, except Mac App Store apps - mas
won't work yet, because I haven't signed into iCloud at this point - this has a dependency on 1Password step to get the password, so we'll re-run brew bundle
again below after 1Password and iCloud are set up.
cd ~/code/dotfiles && brew bundle
Details for using Homebrew with multiple accounts
If there are multiple user accounts on the same Mac, I need to follow a few extra steps:
- Open System Preferences > Users & Groups
- Create a new group called
brew
; add all the users to it - Run these steps:
% sudo chgrp -R brew $(brew --prefix) # Change group to brew for Homebrew
% sudo chmod -R g+w $(brew --prefix) # Allow group members to write inside this directory
% brew doctor # Make sure everything is good
Even with this "shared group" setup, I still run into permissions issues sometimes when running brew bundle
.
Usually I can resolve it by changing ownership to the current user for the Homebrew folder:
% sudo chown -R $USER $(brew --prefix)
% brew bundle # Try installing again
Details for updating Brewfile
This is how I update the Brewfile when I install/uninstall something:
% cd ~/code/dotfiles && brew bundle dump -f
# Then commit the changes to this repo, etc.
I just do this periodically and commit it, it's not automated but the command handles the file for me so I don't have to handwrite it
There's a VS Code task to do this in tasks.json.
Set the computer name from System Preferences > Sharing.
Set up using the camera / phone thing via mobile app.
Sign into iCloud now that 1Password is set up. Disable all the stuff except these:
- Photos
- Keychain
- iCloud Drive
- Find My Mac
Set up a symlink for iCloud Drive at ~/iCloud
:
ln -s ~/Library/Mobile\ Documents/com\~apple\~CloudDocs ~/iCloud
Set up a symlink for Obsidian at ~/amw-obsidian
:
ln -s ~/Library/Mobile\ Documents/iCloud~md~obsidian/Documents/amw-obsidian ~/amw-obsidian
Create a new App Password for Fastmail at Settings > Password & Security > Third Party Apps > App Passwords > New App Password.
Once it's created, download the profile with the link it provides, and open System Preferences > Profile and install it.
After setting up 1Password and iCloud above, run the Homebrew install step again to install Mac App Store apps.
cd ~/code/dotfiles && brew bundle # The `mas` steps should complete now that we're signed into iCloud
Restore app settings from mackup
Copy the configuration to the home directory because I don't use the default
cp ~/code/dotfiles/mackup/.mackup.cfg ~/
Copy the custom config directory for custom apps
cp -r ~/code/dotfiles/mackup/.mackup ~/.mackup
Restore all the settings
mackup restore
Set up SSH key.
Details for setting up SSH key
(These steps are borrowed from this article: Generating a new SSH key and adding it to the ssh-agent - GitHub Docs)
Create a key and set the passphrase to the same as the login password for macOS:
% ssh-keygen -t ed25519 -C "<my email address>"
Add the key to SSH agent on macOS:
% eval "$(ssh-agent -s)"
% ssh-add -K ~/.ssh/id_ed25519
Copy the public key to the clipboard then go to GitHub Settings > SSH and GPG keys and add it:
pbcopy < ~/.ssh/id_ed25519.pub
Test SSH connection to GitHub:
ssh -T git@github.com
Install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
Close and reopen the terminal, then install the lastest available version of Node:
nvm install node