edit command opens files or symlinks in your source state in your default editor. If no targets are specified, it opens the entire source directory.
Usage
Description
Theedit command allows you to modify files in the source state using your configured editor. When you edit files:
- Encrypted files are automatically decrypted to a temporary directory, and re-encrypted when you save
- Hard links are created (when supported) so the editor sees the target filename, helping with syntax highlighting
- Templates preserve their
.tmplextension for proper editor highlighting
Flags
Apply the target immediately after editing. Ignored if there are no targets. Can be configured via
edit.apply in the config file.Invoke the editor with a hard link to the source file with a name matching the target filename. This helps the editor determine the file type correctly. Can be configured via
edit.hardlink in the config file.Note: Creating hardlinks is not possible between different filesystems. If your tempDir resides on a different filesystem (e.g., a tmpfs), this won’t work.Automatically apply changes when files are saved. Can be configured via
edit.watch in the config file.Limitations:- Only available when targets are specified (not for directory-wide editing)
- All edited files are applied when any file is saved
- Only the edited files are watched, not dependent files like
.chezmoitemplates - Only works on operating systems supported by fsnotify
- Only works if
edit.hardlinkis enabled and functional
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).Recreate the config file from the template after editing.
Examples
Edit a specific file
~/.local/share/chezmoi/dot_bashrc in your editor.
Edit and apply immediately
~/.bashrc.
Edit with auto-apply on save
Edit the entire source directory
~/.local/share/chezmoi in your editor (useful for IDEs like VS Code).
Edit multiple files
Editor Configuration
Set your preferred editor using theVISUAL or EDITOR environment variable, or configure it in your chezmoi config file: