CtrlK
BlogDocsLog inGet started
Tessl Logo

pantheon-ai/chezmoi

Expert assistant for chezmoi dotfiles management. Use when: "add this file to chezmoi", "make this a template", "encrypt this secret", "apply on a new machine", "run script only once", "manage dotfiles across machines". Examples: - user: "Track my .zshrc with chezmoi" → chezmoi add ~/.zshrc - user: "Make my .gitconfig machine-specific" → convert to .tmpl, use {{ .chezmoi.hostname }} - user: "Run a script only on first apply" → once_ prefix - user: "Sync to a new laptop" → chezmoi init --apply $GITHUB_USERNAME - user: "Why isn't my file being applied?" → diagnose source attribute, diff, doctor

96

Quality

96%

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Advisory

Suggest reviewing before use

Overview
Quality
Evals
Security
Files

templates.mdchezmoi-assistant/references/

Chezmoi Templates Reference

chezmoi uses Go's text/template with missingkey=error by default (missing keys raise an error).

Built-in Variables

{{ .chezmoi.hostname }}     — machine hostname
{{ .chezmoi.os }}           — "linux", "darwin", "windows"
{{ .chezmoi.arch }}         — "amd64", "arm64"
{{ .chezmoi.username }}     — current user
{{ .chezmoi.homeDir }}      — home directory path
{{ .chezmoi.sourceDir }}    — chezmoi source directory path
{{ .chezmoi.group }}        — current user's primary group
{{ .chezmoi.kernel.osRelease.id }}  — e.g. "ubuntu", "fedora" (Linux)

Inspect all variables: chezmoi data

Conditionals

{{- if eq .chezmoi.os "darwin" }}
export BROWSER=open
{{- else if eq .chezmoi.os "linux" }}
export BROWSER=xdg-open
{{- end }}
{{- if eq .chezmoi.hostname "work-laptop" }}
export HTTP_PROXY=http://proxy.corp:3128
{{- end }}

Custom Data

Add to ~/.config/chezmoi/chezmoi.toml:

[data]
  email = "alice@example.com"
  workMachine = true

Use in templates: {{ .email }}, {{ .workMachine }}

Password Manager Functions

# 1Password
{{ onepasswordRead "vault" "item" "field" }}

# Bitwarden
{{ bitwarden "item" "field" }}

# LastPass
{{ lastpass "item" "field" }}

# gopass
{{ gopass "path/to/secret" }}

# keyring (macOS Keychain / libsecret)
{{ keyring "service" "username" }}

Sprig Functions

chezmoi includes the Sprig template library (see chezmoi.io/reference/templates/functions/ for the full list):

{{ "hello" | upper }}              → HELLO
{{ list "a" "b" "c" | join "," }} → a,b,c
{{ env "HOME" }}                   → /home/alice
{{ include "other-file" . }}       → render another template file

Debugging Templates

# Preview rendered output without applying
chezmoi cat ~/.zshrc

# Render from stdin
echo '{{ .chezmoi.os }}' | chezmoi execute-template

# Render a specific source file
chezmoi execute-template < ~/.local/share/chezmoi/dot_zshrc.tmpl

Template Options

Override missingkey=error in chezmoi.toml:

[template]
  options = ["missingkey=zero"]

Whitespace Control

Use - to strip whitespace:

{{- if eq .chezmoi.os "darwin" -}}
  ...
{{- end -}}

chezmoi-assistant

SKILL.md

tile.json