chezmoi
cross-platform dotfile manager with templating
TLDR
Initialize dotfiles
SYNOPSIS
chezmoi command [options]
DESCRIPTION
chezmoi manages dotfiles across multiple machines. It uses a source directory (typically a git repository at ~/.local/share/chezmoi) to store the desired state of dotfiles, then applies that state to the home directory.
The tool supports Go templates for machine-specific configurations, allowing a single source repository to produce different files on different machines based on hostname, OS, or custom data. Secrets can be managed through integrations with password managers like 1Password, Bitwarden, and pass, or via encrypted files using age or gpg.
Unlike symlink-based managers like GNU Stow, chezmoi copies files to their destinations, meaning the target files are ordinary files that work with any tool.
PARAMETERS
init [repo]
Initialize chezmoiadd target
Add file to source stateapply [target]
Apply changes to destinationedit target
Edit source stateupdate
Pull and apply changesdiff [target]
Show differencescd
Open shell in source directorydata
Show template data
CONFIGURATION
~/.config/chezmoi/chezmoi.toml
Main configuration file. Sets source directory, merge tool, diff settings, encryption method, and secret manager integrations.
FEATURES
- Git integration
- Templating (Go templates)
- Machine-specific configurations
- Secret management (encrypted files)
- Cross-platform support
- Automatic initialization
- Dry-run mode
- Script execution
WORKFLOW
chezmoi init https://github.com/username/dotfiles.git
# Add files to manage
chezmoi add ~/.bashrc
chezmoi add ~/.vimrc
# Edit managed file
chezmoi edit ~/.bashrc
# See what would change
chezmoi diff
# Apply changes
chezmoi apply
# Commit and push
chezmoi cd
git add .
git commit -m "Update dotfiles"
git push
# On new machine
chezmoi init --apply https://github.com/username/dotfiles.git
TEMPLATING
Use templates for machine-specific configs:
{{- if eq .chezmoi.hostname "work-laptop" }}
[data]
email = "work@example.com"
{{- else }}
[data]
email = "personal@example.com"
{{- end }}
CAVEATS
Learning curve for templates. Git repo public by default (use private for secrets). Template syntax can be complex. Large binary files not ideal. Requires understanding of Go templates.
HISTORY
chezmoi was created by Tom Payne in 2018 to provide a modern, flexible dotfile manager with templating and cross-platform support.
