Dotfiles Management
Manage this dotfiles repository with chezmoi.
Repository structure
code
dotfiles/
├── .chezmoiroot # Points to "home" as source
├── .chezmoiversion # Minimum chezmoi version
└── home/ # Source directory
├── .chezmoi.toml.tmpl # Config with template vars
├── .chezmoiexternal.toml # External dependencies
├── .chezmoitemplates/ # Reusable templates
│ └── common.tmpl # Logging, utilities
├── .chezmoiscripts/ # Automation scripts
│ ├── packages/ # Homebrew, Node.js, Rust
│ ├── editors/ # VS Code, Vim plugins
│ ├── security/ # GPG import
│ ├── system/darwin/ # macOS settings
│ ├── tools/ # Claude MCP, etc.
│ └── verify/ # Post-deploy checks
├── dot_config/ # ~/.config/ files
└── [other dotfiles]
Common operations
Preview changes
bash
chezmoi diff
Apply changes
bash
chezmoi apply -v
Add a file to chezmoi
bash
chezmoi add ~/.newfile
View rendered template
bash
chezmoi cat ~/.zshrc
Check available template data
bash
chezmoi data
Force refresh externals
bash
chezmoi apply --refresh-externals
Creating new scripts
- •Create in appropriate directory under
home/.chezmoiscripts/ - •Use naming convention:
run_[before|after|onchange]_category_name.sh.tmpl - •Include required header:
bash
{{- if .is_mac -}} #!/bin/bash set -euo pipefail {{ template "common.tmpl" . }} # ... script content {{- end -}}
Template debugging
bash
chezmoi execute-template '{{ .is_mac }}'
chezmoi execute-template '{{ .with_docker }}'