C.W.K.
Stream
Lesson 08 of 14 · published

Dotfiles Strategy

~12 min · dotfiles, deploy, version-control

Level 0Pinger
0 XP0/101 lessons0/12 achievements
0/150 XP to next level150 XP to go0% complete

One repo, every machine identical

Track 4 introduced dotfiles + bootstrap.sh. Fleet management is where dotfiles really pay off — every machine in the fleet runs the same shell, the same git config, the same SSH config, the same editor setup. Onboarding a new machine is one command.

The structure that scales

Repo layout that works for years: dotfiles at the top (synced into ~/), Brewfile for packages, bootstrap.sh for setup, optionally scripts/ for fleet-wide helpers. .gitignore excludes private keys, env files, anything secret.

Code

Repo layout·plaintext
~/dotfiles/
├── .zshrc
├── .gitconfig
├── .ssh/
│   └── config            # ← public — keys are per-machine
├── .config/
│   ├── nvim/
│   ├── starship.toml
│   └── ghostty/
├── Brewfile              # `brew bundle` source of truth
├── bootstrap.sh          # deploy script
├── scripts/              # fleet-wide helpers
│   ├── morning-check.sh
│   └── update-all.sh
├── README.md
└── .gitignore
bootstrap.sh — one command per machine·bash
#!/bin/bash
set -euo pipefail

DOTFILES="$HOME/dotfiles"
REPO="git@github.com:you_username/dotfiles.git"

# Clone or update
if [[ -d "$DOTFILES" ]]; then
    git -C "$DOTFILES" pull --rebase
else
    git clone "$REPO" "$DOTFILES"
fi

# Sync files into ~ (excluding meta files)
rsync -avh --no-perms "$DOTFILES/" "$HOME/" \
    --exclude '.git' \
    --exclude 'bootstrap.sh' \
    --exclude 'Brewfile' \
    --exclude 'README.md' \
    --exclude 'scripts'

# Brew packages
if command -v brew >/dev/null; then
    brew bundle --file="$DOTFILES/Brewfile" || true
fi

# SSH socket directory for ControlMaster
mkdir -p ~/.ssh/sockets
chmod 700 ~/.ssh/sockets

echo 'Dotfiles deployed. Run: source ~/.zshrc'

External links

Exercise

If you don't have a dotfiles repo, create one with at minimum .zshrc, .gitconfig, ~/.ssh/config. Add a bootstrap.sh from the example above. Push to GitHub. On a second Mac, clone and run bootstrap. Confirm both machines now share identical config. That's the fleet-baseline state.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.