Special Files and Directories
All files and directories in the source directory whose name begins with. are ignored by default, unless they are one of the special files or directories listed here. All of these files and directories are optional and are evaluated in a specific order.
Special Files
Processing Order
Special files are processed in the following order:.chezmoiroot- Sets the source state path.chezmoi.$FORMAT.tmpl- Prepares or updates the chezmoi config file.chezmoidata.$FORMAT- Provides data for templates.chezmoitemplates/- Makes templates available for use.chezmoiignore- Determines files to ignore.chezmoiremove- Determines files to remove.chezmoiexternal.$FORMAT- Includes external files and archives.chezmoiversion- Ensures minimum chezmoi version
.chezmoiroot
The .chezmoiroot file is read from the root of the source directory before any other file. It sets the source state path, which affects the location of all other files except .chezmoiversion.
Example
~/.local/share/chezmoi/.chezmoiroot
~/.local/share/chezmoi/home instead of ~/.local/share/chezmoi.
.chezmoi.$FORMAT.tmpl
This file is used by chezmoi init to prepare or update the chezmoi config file. It is also used when a command supports the --init flag, such as chezmoi apply --init.
The file is processed as a template and the result is written to the config file.
Example
~/.local/share/chezmoi/.chezmoi.toml.tmpl
.chezmoidata.$FORMAT
Data files are read before any templates are processed, making their contents available to templates via the . variable.
Supported formats: .json, .jsonc, .toml, .yaml
Example
~/.local/share/chezmoi/.chezmoidata.yaml
dot_gitconfig.tmpl
.chezmoidata/
Directory containing multiple data files. Files are read in lexical order along with any .chezmoidata.$FORMAT files in the source state.
All files in this directory are merged into the template data.
Example
.chezmoiignore
A template file that lists patterns of files to ignore. Each line of the file is a pattern. Blank lines and lines beginning with # are ignored.
Patterns are matched using Go’s filepath.Match and support ** for recursive directory matching.
Example
~/.local/share/chezmoi/.chezmoiignore
.chezmoiremove
A template file that lists patterns of files to remove from the destination directory. The syntax is the same as .chezmoiignore.
Example
~/.local/share/chezmoi/.chezmoiremove
.chezmoiexternal.$FORMAT
Defines external files and archives to include as if they were in the source state. This is useful for including large files or entire directories from external sources.
Supported formats: .json, .jsonc, .toml, .yaml
Example
~/.local/share/chezmoi/.chezmoiexternal.toml
External Entry Types
file: Single file downloadarchive: Archive (tar, tar.gz, tar.bz2, zip) extractiongit-repo: Git repository clone
.chezmoiexternals/
Directory containing multiple external definition files. Files are read in lexical order with any .chezmoiexternal.$FORMAT files.
.chezmoiscripts/
Directory containing scripts that are read, templated, and executed according to their phase attributes (run_after_, run_before_, etc.) and lexical ordering.
This allows you to organize scripts in subdirectories while maintaining control over execution order.
Example
.chezmoitemplates/
Directory containing template files that can be included in other templates using the includeTemplate function.
Example
~/.local/share/chezmoi/.chezmoitemplates/header
dot_bashrc.tmpl
.chezmoiversion
Specifies the minimum version of chezmoi required for the source state. This file is processed before any operation is applied.
Example
~/.local/share/chezmoi/.chezmoiversion
Processing Order Summary
| Order | File/Directory | Purpose |
|---|---|---|
| 1 | .chezmoiroot | Set source state path |
| 2 | .chezmoi.$FORMAT.tmpl | Initialize/update config |
| 3 | .chezmoidata.$FORMAT, .chezmoidata/ | Load template data |
| 4 | .chezmoitemplates/ | Make templates available |
| 5 | .chezmoiignore | Determine ignored files |
| 6 | .chezmoiremove | Determine files to remove |
| 7 | .chezmoiexternal.$FORMAT, .chezmoiexternals/ | Include external resources |
| 8 | .chezmoiversion | Verify chezmoi version |
Related Pages
- Source State Attributes - File naming conventions
- Templates - Template syntax
chezmoi init- Initialize chezmoi