add command adds existing files, directories, or symlinks from your home directory to chezmoi’s source state. If the target is already in the source state, its source state is replaced with its current state in the destination directory.
Usage
Description
When you add a file to chezmoi, it copies the file from your home directory to the source directory, applying any naming conventions (like prefixes for attributes) automatically.Flags
Automatically generate a template by replacing strings that match variable values from the
data section of the config file with their respective config names as template strings. Longer substitutions occur before shorter ones. This implies the --template option.Warning: Uses a greedy algorithm which occasionally generates templates with unwanted variable substitutions. Carefully review any templates it generates.Add files that should exist, irrespective of their contents. Sets the
create_ attribute on the added file. A file will be created with the given contents if it doesn’t exist, but its contents won’t be changed if it already exists. Useful for managing files with an initial state that shouldn’t be changed by chezmoi afterwards.Encrypt files using the defined encryption method. Can be configured via
add.encrypt in the config file.Set the
exact attribute on added directories. Directories with the exact attribute are statefully synced between target and source directories.Warning: When running re-add, any files deleted from the exact target directory will be removed from the source directory. Likewise, any files added to the exact target directory will be added to the source directory.If the last part of a target is a symlink, add the target of the symlink instead of the symlink itself.
Create a new file if the target does not exist.
Interactively prompt before adding each file.
Suppress warnings about adding ignored entries.
Recurse into subdirectories.
Action to take when a secret is found when adding a file. Options:
ignore, warning, error. Can be configured via add.secrets in the config file.Set the
template attribute on added files and symlinks.When adding a symlink to an absolute path in the source directory or destination directory, create a symlink template with
.chezmoi.sourceDir or .chezmoi.homeDir. Useful for creating portable absolute symlinks. Can be configured via add.templateSymlinks in the config file.Exclude entry types (comma-separated:
dirs, files, remove, scripts, symlinks, always, encrypted, externals, templates).Include only specified entry types (comma-separated:
dirs, files, remove, scripts, symlinks, always, encrypted, externals, templates).Examples
Add a single file
~/.local/share/chezmoi/dot_bashrc.
Add a file as a template
~/.local/share/chezmoi/dot_gitconfig.tmpl.
Add and encrypt a private file
Add a directory recursively
Add an exact directory
exact attribute ensures the directory in your home directory exactly matches the source state.