LinuxCommandLibrary

chezmoi

cross-platform dotfile manager with templating

TLDR

Initialize dotfiles

$ chezmoi init
copy
Add file to dotfiles
$ chezmoi add [~/.bashrc]
copy
Apply changes
$ chezmoi apply
copy
Edit dotfile
$ chezmoi edit [~/.bashrc]
copy
Update from remote
$ chezmoi update
copy
Show differences
$ chezmoi diff
copy

SYNOPSIS

chezmoi command [options]

DESCRIPTION

chezmoi manages dotfiles across multiple machines. It uses a source directory (typically a git repository at ~/.local/share/chezmoi) to store the desired state of dotfiles, then applies that state to the home directory.
The tool supports Go templates for machine-specific configurations, allowing a single source repository to produce different files on different machines based on hostname, OS, or custom data. Secrets can be managed through integrations with password managers like 1Password, Bitwarden, and pass, or via encrypted files using age or gpg.
Unlike symlink-based managers like GNU Stow, chezmoi copies files to their destinations, meaning the target files are ordinary files that work with any tool.

PARAMETERS

init [repo]

Initialize chezmoi
add target
Add file to source state
apply [target]
Apply changes to destination
edit target
Edit source state
update
Pull and apply changes
diff [target]
Show differences
cd
Open shell in source directory
data
Show template data

CONFIGURATION

~/.config/chezmoi/chezmoi.toml

Main configuration file. Sets source directory, merge tool, diff settings, encryption method, and secret manager integrations.

FEATURES

- Git integration
- Templating (Go templates)
- Machine-specific configurations
- Secret management (encrypted files)
- Cross-platform support
- Automatic initialization
- Dry-run mode
- Script execution

WORKFLOW

$ # Initialize with GitHub repo
chezmoi init https://github.com/username/dotfiles.git

# Add files to manage
chezmoi add ~/.bashrc
chezmoi add ~/.vimrc

# Edit managed file
chezmoi edit ~/.bashrc

# See what would change
chezmoi diff

# Apply changes
chezmoi apply

# Commit and push
chezmoi cd
git add .
git commit -m "Update dotfiles"
git push

# On new machine
chezmoi init --apply https://github.com/username/dotfiles.git
copy

TEMPLATING

Use templates for machine-specific configs:

$ # .chezmoi.toml.tmpl
{{- if eq .chezmoi.hostname "work-laptop" }}
[data]
    email = "work@example.com"
{{- else }}
[data]
    email = "personal@example.com"
{{- end }}
copy

CAVEATS

Learning curve for templates. Git repo public by default (use private for secrets). Template syntax can be complex. Large binary files not ideal. Requires understanding of Go templates.

HISTORY

chezmoi was created by Tom Payne in 2018 to provide a modern, flexible dotfile manager with templating and cross-platform support.

SEE ALSO

dotfiles(1), git(1), stow(1)

> TERMINAL_GEAR

Curated for the Linux community

BOSGAME Mini PC N95, Intel 12th Mini Computers| 16GB DDR4 RAM| 512GB M.2 2280 SSD| 4K 60HZ Triple Displays by Dual HDMI+Type-C, 6W TDP Quiet Mini PC, WIFI5, BT 5.0 Office

BOSGAME Mini PC N95, Intel 12th Mini Computers| 16GB DDR4 RAM| 512GB M.2 2280 SSD| 4K 60HZ Triple Displays by Dual HDMI+Type-C, 6W TDP Quiet Mini PC, WIFI5, BT 5.0 Office

$239.99
Lenovo Gen 13 ThinkPad X1 Carbon Touchscreen Laptop with Intel Ultra 7 265U Processor, 14" WUXGA 100% sRGB, 32GB DDR5 RAM, 1TB NVMe Performance SSD, FHD+ IR+ RGB Camera, and Windows 11 Pro

Lenovo Gen 13 ThinkPad X1 Carbon Touchscreen Laptop with Intel Ultra 7 265U Processor, 14" WUXGA 100% sRGB, 32GB DDR5 RAM, 1TB NVMe Performance SSD, FHD+ IR+ RGB Camera, and Windows 11 Pro

$1,589.00
Raspberry Pi 5 8GB

Raspberry Pi 5 8GB

$134.50
Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community

GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

$739.99
Raspberry Pi 5 8GB

Raspberry Pi 5 8GB

$134.50
Lenovo Gen 13 ThinkPad X1 Carbon Touchscreen Laptop with Intel Ultra 7 265U Processor, 14" WUXGA 100% sRGB, 32GB DDR5 RAM, 1TB NVMe Performance SSD, FHD+ IR+ RGB Camera, and Windows 11 Pro

Lenovo Gen 13 ThinkPad X1 Carbon Touchscreen Laptop with Intel Ultra 7 265U Processor, 14" WUXGA 100% sRGB, 32GB DDR5 RAM, 1TB NVMe Performance SSD, FHD+ IR+ RGB Camera, and Windows 11 Pro

$1,589.00