Skip to content

Latest commit

 

History

History
130 lines (96 loc) · 3.81 KB

MACOS.md

File metadata and controls

130 lines (96 loc) · 3.81 KB

macOS Setup

Quick Start

For a new Mac, run this one-liner:

git clone https://github.com/TonyCTHsu/dotfiles.git ~/dotfiles && ~/dotfiles/install.sh

Manual Setup

If you prefer manual control:

# 1. Clone the repository
git clone https://github.com/TonyCTHsu/dotfiles.git ~/dotfiles

# 2. Install Homebrew (if needed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# 3. Install chezmoi
brew install chezmoi

# 4. Install dependencies
cd ~/dotfiles && brew bundle

# 5. Install dotfiles
#    (--source only affects this one invocation and isn't persisted, so also
#    write it to chezmoi.toml -- otherwise every later plain `chezmoi apply`
#    falls back to the default source dir and fails)
mkdir -p ~/.config/chezmoi
cat > ~/.config/chezmoi/chezmoi.toml <<'EOF'
sourceDir = "$HOME/dotfiles"
EOF
chezmoi apply -v

# 6. Change shell to zsh (if needed)
chsh -s $(which zsh)

SSH and Commit Signing

SSH signing keys live on the machine, not in an agent you approve by hand. Key files are encrypted in ~/.ssh. Passphrases sit in the login keychain. The macOS ssh-agent loads the keys at every login. 1Password is only the master copy things restore from. Nothing in the git path prompts you.

How the pieces fit

  • private_dot_ssh/run_once_import-from-1password.sh runs on the first chezmoi apply of a machine. It fetches the personal signing key from 1Password with op. It prompts once for a new passphrase, writes the encrypted key file, and stores the passphrase in the login keychain.
  • run_onchange_load-personal-signing-key.sh installs the LaunchAgent that loads ~/.ssh/id_github_signing into the agent at every login.
  • dot_gitconfig makes the personal identity the default for every repo.
  • ~/.gitconfig.work-routing and ~/.ssh/config.local are untracked, machine-local, and exist only on work machines. See the next section.

If you ever delete ~/.ssh/id_github_signing on purpose, run_once_ will not re-import it. Re-run the import by hand or reset chezmoi's state for it.

Test signing

ssh -T git@github.com
git commit --allow-empty -m "Test signed commit"
git log --show-signature -1

Work Machines (DataDog)

On a machine that also does DataDog work, two extra untracked files carry all the work-specific config. Copy them by hand:

  • ~/.ssh/config.local includes the git-config-tool ssh_config.
  • ~/.gitconfig.work-routing re-applies the work identity for repos with DataDog or ddoghq-family remotes. Without it, work repos silently commit as personal, and GitHub rejects the push with a key error.

If the pieces are missing, git config-tool doctor fails its include check. The tool is the tripwire.

For machines set up before git-config-tool v4, run git config-tool system-migrate, log out and back in, then run it once more and finish with git config-tool setup.

Identity routing after that: personal by default, work identity by remote URL (DataDog/**, ddoghq family).

Updating Your Dotfiles

After making changes to your dotfiles:

# Re-run dotfiles installation
chezmoi apply

# Install new packages (if Brewfile changed)
brew bundle

# Update vim plugins (if vimrc.bundles changed)
vim -u ~/.vimrc.bundles +PlugUpdate +PlugClean! +qa

Troubleshooting

Fixing shell errors

Restart the shell when errors appear after installation:

# Restart your shell
exec zsh

# Or restart your terminal completely

Permission Issues

If you get permission errors:

# Fix permissions on your home directory
sudo chown -R $(whoami):staff ~

1Password SSH Issues

If Git signing does not work:

  1. Verify 1Password SSH agent is enabled
  2. Check that your public key is in ~/.ssh/allowed_signers
  3. Verify the key is added to GitHub as a signing key
  4. Test with ssh -T git@github.com