/dotfiles

👨‍💻 My settings and configuration files

Primary LanguageRuby

dotfiles

These are my configuration files and notes for setting up a new Mac.

Do the following, in this order:

  1. Clone this repo
  2. Install oh-my-zsh
  3. Install Rosetta 2 (for M1 Macs)
  4. Install Homebrew and packages
  5. Set computer name
  6. Set up 1Password
  7. Sign into iCloud
  8. Sign into Fastmail
  9. Install Mac App Store apps
  10. Restore Mackup
  11. Set up SSH
  12. Set up Node

Clone this repo

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

oh-my-zsh

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Rosetta 2

sudo softwareupdate --install-rosetta

Homebrew

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

Multi-user setup

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:

  1. Open System Preferences > Users & Groups
  2. Create a new group called brew; add all the users to it
  3. 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

Brewfile

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.

Computer Name

Set the computer name from System Preferences > Sharing.

1Password

Set up using the camera / phone thing via mobile app.

iCloud

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

Fastmail

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.

Mac App Store

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

Mackup

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

SSH

Set up SSH key.

Details for setting up SSH key

GitHub

(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

Node

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