Files

2.0 KiB

chezmoi

chezmoi is a dotfile manager that keeps configuration files synchronized across machines using a git-backed source directory.

Setup

Configuration

Config file: ~/.config/chezmoi/chezmoi.toml

[git]
    autoCommit = true
    autoPush = true

[merge]
command = "bash"
args = [
    "-c",
    "cp {{ .Target | quote }} {{ printf \"%s.base\" .Target | quote }} && code --new-window --wait --merge {{ .Destination | quote }} {{ .Target | quote }} {{ printf \"%s.base\" .Target | quote }} {{ .Source | quote }}",
]
  • autoCommit: Automatically commits changes after chezmoi apply
  • autoPush: Automatically pushes to remote after commit
  • merge: Custom merge command using VS Code's merge editor

Source Directory

~/.local/share/chezmoi/ - Git repository containing managed dotfiles

Managed Dotfiles

File/Directory Description
.bash_aliases Shell aliases
.bashrc Bash configuration
.tmux.conf Tmux configuration
.config/opencode/ OpenCode AI assistant config
.gemini/settings.json Gemini CLI settings
.ssh/authorized_keys SSH authorized keys (private)

OpenCode Config

The .config/opencode/ directory includes:

  • opencode.jsonc - Main OpenCode configuration
  • oh-my-opencode-slim.json - Slim preset configuration
  • executable_opencode-tmux-launch.sh - Script to launch OpenCode in tmux

Common Commands

# Edit a dotfile in the source directory
chezmoi edit ~/.bashrc

# Apply changes to the home directory
chezmoi apply

# See what would change
chezmoi diff

# Add a new file to chezmoi
chezmoi add ~/.newconfig

# Edit the config file
chezmoi edit-config

# Initialize chezmoi on a new machine
chezmoi init https://github.com/username/dotfiles.git

Workflow

  1. Edit dotfiles with chezmoi edit (opens source file)
  2. Apply changes with chezmoi apply
  3. Changes auto-commit and push to git remote