Skip to main content

Configuration File

chezmoi searches for its configuration file according to the XDG Base Directory Specification. The base name of the config file is chezmoi. If multiple configuration file formats are present, chezmoi will report an error. In most installations, the config file will be read from $HOME/.config/chezmoi/chezmoi.$FORMAT (%USERPROFILE%/.config/chezmoi/chezmoi.$FORMAT on Windows), where $FORMAT is one of json, jsonc, toml, or yaml. The config file can be set explicitly with the --config command line option. By default, the format is detected based on the extension of the config file name, but can be overridden with the --config-format command line option.

Configuration File Formats

chezmoi supports the following configuration file formats:
  • JSON (.json): Standard JSON format
  • JSONC (.jsonc): JSON with comments
  • TOML (.toml): Tom’s Obvious, Minimal Language
  • YAML (.yaml or .yml): YAML Ain’t Markup Language

Global Configuration Options

Directory Paths

OptionTypeDefaultDescription
sourceDirstring~/.local/share/chezmoiThe source directory
destDirstring~The destination directory
cacheDirstringOS-specificThe cache directory
persistentStatestringOS-specificPath to persistent state file
workingTreestringSame as sourceDirThe git working tree
tempDirstringOS temp dirTemporary directory for chezmoi operations
scriptTempDirstringOS temp dirTemporary directory for scripts

Display Options

OptionTypeDefaultDescription
colorstring/boolautoColorize output (true, false, or auto)
formatstring-Output format (json, yaml, etc.)
pagerstring$PAGER or lessPager command
pagerArgs[]string-Arguments to pass to pager
progressboolautoShow progress bars
verboseboolfalseEnable verbose output

Behavior Options

OptionTypeDefaultDescription
modestringfileMode (file or symlink)
umaskintOS defaultFile mode creation mask
safeboolfalseSafe mode - require confirmation for destructive operations
interactiveboolfalsePrompt for confirmation
lessInteractiveboolfalseReduce interactive prompts

Encryption Options

OptionTypeDefaultDescription
encryptionstring-Encryption tool (age or gpg)
age.commandstringageAge command
age.suffixstring.ageSuffix for age-encrypted files
gpg.commandstringgpgGPG command
gpg.suffixstring.ascSuffix for GPG-encrypted files

Git Configuration

OptionTypeDefaultDescription
git.autoAddboolfalseAutomatically add changes to git
git.autoCommitboolfalseAutomatically commit changes
git.autoPushboolfalseAutomatically push changes to remote
git.commandstringgitGit command to use

Template Configuration

OptionTypeDefaultDescription
template.options[]string["missingkey=error"]Template execution options

Environment Variables

OptionTypeDescription
envmap[string]stringAdditional environment variables for all commands
scriptEnvmap[string]stringAdditional environment variables for scripts only

Custom Data

OptionTypeDescription
datamap[string]anyCustom template variables accessible via .variable

Password Manager Configurations

Each password manager can be configured with specific options:

1Password

OptionTypeDefaultDescription
onepassword.commandstringop1Password CLI command
onepassword.cachebooltrueEnable caching
onepassword.promptbooltruePrompt for authentication

Bitwarden

OptionTypeDefaultDescription
bitwarden.commandstringbwBitwarden CLI command

LastPass

OptionTypeDefaultDescription
lastpass.commandstringlpassLastPass CLI command

Pass

OptionTypeDefaultDescription
pass.commandstringpassPass command

Vault

OptionTypeDefaultDescription
vault.commandstringvaultVault CLI command
See Password Manager Functions for usage details.

Hooks

Hooks allow you to run commands before or after specific chezmoi operations:
[hooks.read-source-state.pre]
command = ".local/share/chezmoi/.validate.sh"

[hooks.apply.post]
command = "notify-send"
args = ["chezmoi", "Applied successfully"]
Available hook points:
  • read-source-state
  • apply

Interpreters

Configure interpreters for scripts:
[interpreters.ps1]
command = "pwsh"
args = ["-NoLogo"]

Examples

TOML Configuration

~/.config/chezmoi/chezmoi.toml
sourceDir = "~/.dotfiles"

[data]
email = "[email protected]"

[git]
autoCommit = true
autoPush = true

[encryption]
age.identity = "~/.config/sops/age/keys.txt"

YAML Configuration

~/.config/chezmoi/chezmoi.yaml
sourceDir: ~/.dotfiles
data:
  email: [email protected]
git:
  autoCommit: true
  autoPush: true

JSON Configuration

~/.config/chezmoi/chezmoi.json
{
  "sourceDir": "~/.dotfiles",
  "data": {
    "email": "[email protected]"
  },
  "git": {
    "autoCommit": true,
    "autoPush": true
  }
}
  • chezmoi init - Initialize chezmoi configuration
  • chezmoi cat-config - Print the configuration file
  • chezmoi data - Print template data

Build docs developers (and LLMs) love