| name | chezmoi-source-state |
| description | Work with the chezmoi source directory: file naming prefixes, adding/removing files, externals (.chezmoiexternal for external files, archives, and git repos), special directories (.chezmoiignore, .chezmoitemplates/), and git operations. |
Source directory location
Default: ~/.local/share/chezmoi
Override with sourceDir in config or --source flag.
Open a shell in it: chezmoi cd
The source directory is a plain git repository.
File name prefix system
Multiple prefixes compose left to right.
Attribute prefixes
| Prefix | Meaning |
|---|
dot_ | File/dir name starts with . (e.g., dot_bashrc → .bashrc) |
private_ | File permissions 0600, directory 0700 |
executable_ | File permissions 0755 |
readonly_ | File permissions are read-only |
empty_ | Create the file even if its content is empty |
encrypted_ | File is encrypted (age or gpg) |
exact_ | Directory: remove target files not present in source |
literal_ | File name is used as-is, no prefix interpretation |
run_ | File is a script, not a dotfile |
symlink_ | Create as a symlink in the target |
modify_ | Script that modifies an existing target file |
create_ | Create file only if it does not already exist |
Suffix
| Suffix | Meaning |
|---|
.tmpl | File is a Go template; rendered before applying |
.age | Encrypted with age (added automatically, not manual) |
.asc | Encrypted with gpg (added automatically, not manual) |
Read more about attributes in references/attributes.md
Examples
| Source name | Target path | Notes |
|---|
dot_bashrc | ~/.bashrc | Simple dotfile |
private_dot_ssh/ | ~/.ssh/ | Directory with 0700 |
private_dot_ssh/config | ~/.ssh/config | File inside private dir |
executable_dot_local/bin/script.sh | ~/.local/bin/script.sh | Executable script |
dot_gitconfig.tmpl | ~/.gitconfig | Rendered as template |
encrypted_private_dot_netrc.age | ~/.netrc | Encrypted, private |
symlink_dot_vim | ~/.vim | Symlink |
exact_dot_config/git/ | ~/.config/git/ | Exact dir, removes unlisted files |
Adding files to source state
chezmoi add ~/.bashrc
chezmoi add --follow ~/.config/nvim
chezmoi add --encrypt ~/.ssh/id_ed25519
chezmoi add --template ~/.gitconfig
Read more about attributes in references/attributes.md
Inspecting the source state
chezmoi managed
chezmoi source-path ~/.bashrc
chezmoi cat ~/.bashrc
chezmoi archive
Removing files from source state
chezmoi forget ~/.bashrc
chezmoi destroy ~/.bashrc
.chezmoiignore
Create ~/.local/share/chezmoi/.chezmoiignore to exclude patterns from management:
README.md
*.swp
.DS_Store
Supports Go template syntax.
Read more about special files and directories in references/special-files-directories.md
.chezmoiexternal.toml
Fetch external files, archives, or git repos into the target as if they were in the source state:
[".oh-my-zsh"]
type = "archive"
url = "https://github.com/ohmyzsh/ohmyzsh/archive/master.tar.gz"
exact = true
stripComponents = 1
refreshPeriod = "168h"
Note that stripComponents trims leading path segments from the archive.
Read more about external types and all fields in references/externals.md
.chezmoitemplates/
Store shared template fragments here.
Use in other templates: {{ template "shared-fragment" . }}
Git operations on the source directory
chezmoi git status
chezmoi git add .
chezmoi git commit -- -m "chore: update dotfiles"
chezmoi git push
Or cd $(chezmoi source-path) and use git directly.
Read more about git operations in references/git-operations.md