Loading...
Loading...
Comprehensive chezmoi dotfile management skill for creating, modifying, and maintaining dotfile templates, configuration files, scripts, and external resources. Use when working with chezmoi for creating new dotfile templates (.tmpl files) with Go template syntax, managing .chezmoi.toml.tmpl configuration and .chezmoidata, configuring .chezmoiexternal files for external resources, writing run_once/run_onchange/run_before/run_after scripts, integrating password managers for secrets, managing cross-platform configurations, and handling conditional logic based on OS/architecture/hostname. This skill includes comprehensive reference documentation for all chezmoi features and can consult the latest chezmoi documentation via Context7.
npx skill4agent add faintghost/skills chezmoi-configchezmoi applychezmoi apply --forcechezmoi updatechezmoi applychezmoi diffchezmoi apply --dry-runchezmoi doctorchezmoi datachezmoi managedchezmoi unmanagedchezmoi ignoredchezmoi execute-template < file.tmplchezmoi state dumpchezmoi verifychezmoi cdchezmoi source-pathchezmoi applychezmoi add --template ~/.gitconfigchezmoi cd
$EDITOR dot_gitconfig.tmpl[user]
name = {{ .name }}
{{- if eq .chezmoi.os "darwin" }}
[credential]
helper = osxkeychain
{{- end }}.chezmoiexternal.toml.tmpl[".oh-my-zsh"]
type = "archive"
url = "https://github.com/ohmyzsh/ohmyzsh/archive/master.tar.gz"
exact = true
stripComponents = 1run_onchange_install-packages.sh.tmpl{{ if eq .chezmoi.os "darwin" -}}
#!/bin/bash
brew install git vim ripgrep
{{ end -}}[user]
name = {{ .name }}
email = {{ .email }}
{{- if eq .chezmoi.os "darwin" }}
[credential]
helper = osxkeychain
{{- else if eq .chezmoi.os "linux" }}
[credential]
helper = cache
{{- end }}[data]
name = "John Doe"
email = "john@example.com"{{- if (bitwarden "github") }}
[github]
token = {{ (bitwarden "github").login.password }}
{{- end }}{{ if eq .chezmoi.os "darwin" -}}
#!/bin/bash
brew bundle --file=/dev/stdin <<EOF
{{ range .packages.darwin.brews -}}
brew "{{ . }}"
{{ end -}}
EOF
{{ else if eq .chezmoi.os "linux" -}}
#!/bin/bash
sudo apt install -y {{ range .packages.linux }}{{ . }} {{ end }}
{{ end -}}darwin:
brews:
- git
- vim
- ripgrep
linux:
- git
- vim
- ripgrep
- fd-find[".vim/autoload/plug.vim"]
type = "file"
url = "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
[".oh-my-zsh"]
type = "archive"
url = "https://github.com/ohmyzsh/ohmyzsh/archive/master.tar.gz"
exact = true
stripComponents = 1
refreshPeriod = "168h"
[".local/bin/age"]
type = "archive-file"
url = "https://github.com/FiloSottile/age/releases/download/v1.1.1/age-v1.1.1-{{ .chezmoi.os }}-{{ .chezmoi.arch }}.tar.gz"
path = "age/age"
executable = true{{- $editor := promptChoice "favorite editor" ["vim" "neovim" "vscode"] -}}
[data]
name = "{{ promptString "your name" }}"
email = "{{ promptString "your email" }}"
editor = {{ $editor }}
{{ if promptBool "enable work config?" -}}
[data.work]
enabled = true
work_email = "{{ promptString "work email" }}"
{{ end }}README.md
*.log
{{- if ne .chezmoi.hostname "work-laptop" }}
.work
{{- end }}
{{- if eq .chezmoi.os "windows" }}
Documents/*
!Documents/*PowerShell/
{{- end }}chezmoi managedchezmoi unmanagedchezmoi unmanaged~/.config/chezmoi/chezmoi.tomldot_config/chezmoi/chezmoi.toml.tmplprivate_dot_config/chezmoi/chezmoi.toml.tmpl~/.config/chezmoichezmoi managedchezmoi.toml#!/bin/bash
{{ if eq .chezmoi.os "darwin" -}}
if ! command -v brew &> /dev/null; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
{{ end -}}# Clear all run_once script state
chezmoi state delete-bucket --bucket=scriptState| Variable | Description | Example |
|---|---|---|
| Operating system | |
| Architecture | |
| Machine hostname | |
| Current user | |
| Home directory | |
| Source state directory | |
| Environment variables | |
{{ if eq .chezmoi.os "darwin" }}
# macOS-specific
{{ else if eq .chezmoi.os "linux" }}
# Linux-specific
{{ end }}{{ range .packages.darwin.brews -}}
brew "{{ . }}"
{{ end -}}{{ .name | quote }} # Add quotes
{{ .chezmoi.homeDir }} # No trimming
{{- "content" -}} # Trim whitespace.chezmoi.os.chezmoi.archrun_once_000-bootstrap.sh.tmplchezmoi execute-template < file.tmpl# When in doubt, ask for the latest docs
"Check the chezmoi documentation for [topic]".tmpl.chezmoiignore{,.tmpl}# ⚠️ FORBIDDEN - Apply all changes (must run manually)
chezmoi apply
# Dry run (preview changes) - SAFE
chezmoi apply --dry-run
# ⚠️ FORBIDDEN - Update source state (may change managed files)
chezmoi update
# Edit source state - SAFE
chezmoi cd
# Add file as template - SAFE
chezmoi add --template ~/.config/file
# Verify configuration - SAFE
chezmoi doctor
# View all template data - SAFE
chezmoi data
# List ignored files - SAFE
chezmoi ignored
# Test template (preview output) - SAFE
chezmoi execute-template < ~/.local/share/chezmoi/dot_file.tmpl
# View run_once state - SAFE
chezmoi state dump
# Clear run_once script state (use with caution) - SAFE
chezmoi state delete-bucket --bucket=scriptState
# Clear run_onchange script state (use with caution) - SAFE
chezmoi state delete-bucket --bucket=entryState
# See what would change - SAFE
chezmoi diff
# Verify files match expected state - SAFE
chezmoi verify~/.local/share/chezmoi/
├── .chezmoi.toml.tmpl # Main configuration (optional)
├── .chezmoiexternal.toml.tmpl # External resources (optional)
├── .chezmoiignore.tmpl # Ignore rules (template-aware, optional)
├── .chezmoidata/
│ ├── packages.yaml # Custom data
│ └── work.yaml
├── dot_gitconfig.tmpl # Regular templates
├── dot_zshrc.tmpl
├── run_once_000-bootstrap.sh.tmpl
├── run_onchange_install-packages.sh.tmpl
└── run_after_dot_vimrc.sh.tmplchezmoi updatechezmoi diffchezmoi apply --dry-runchezmoi apply --verbosechezmoi diffchezmoi doctorchezmoi execute-template < template-file