The primary goal of chezmoi is to manage configuration files across multiple machines with different requirements. chezmoi uses Go’s text/template syntax for customization.
# ~/.local/share/chezmoi/dot_bashrc.tmpl# common configexport EDITOR=vi# machine-specific configuration{{- if eq .chezmoi.hostname "work-laptop" }}# this will only be included in ~/.bashrc on work-laptopexport WORK_ENV=production{{- end }}
The - inside template brackets removes surrounding whitespace. This prevents extra newlines in your output.
Use .chezmoiignore templates for coarse-grained control:
README.md{{- if ne .chezmoi.hostname "work-laptop" }}.work # only manage .work on work-laptop{{- end }}
Use ne (not equal) to express “only install if”. We say “ignore unless work-laptop” instead of “install if work-laptop” because chezmoi installs everything by default.