As a developer who works across multiple machines—laptop, desktop, cloud instances, and various development environments—I used to dread setting up a new computer. The thought of manually configuring my shell, editor settings, aliases, and countless other dotfiles was enough to make me postpone migrations for months.
Then I discovered Chezmoi, and everything changed.
Before Chezmoi, my workflow looked something like this:
I tried various approaches: storing dotfiles in Dropbox, creating my own Git repository with symlinks, even writing custom shell scripts. Each solution had its own problems and maintenance overhead.
Chezmoi is a dotfile manager that handles the complexity of managing configuration files across multiple machines. But it’s so much more than just a sync tool—it’s a complete configuration management system designed specifically for personal use.
Here’s how Chezmoi transformed my daily workflow:
# Install chezmoi
sh -c "$(curl -fsLS chezmoi.io/get)"
# Initialize with your dotfiles repository
chezmoi init https://github.com/yourusername/dotfiles.git
# Apply the configuration
chezmoi apply
I created two essential scripts that make managing configurations effortless:
sync-and-save.sh - My go-to script for keeping everything in sync:
#!/bin/bash
set -e
# Optional: Go to your chezmoi working directory
cd "$(chezmoi source-path)"
# Apply any changes (sync system with dotfiles)
echo "Applying chezmoi changes..."
chezmoi apply
# Git add/commit/push
echo "Syncing to git..."
# Optional: Check if anything changed
if [ -n "$(git status --porcelain)" ]; then
git add .
COMMIT_MSG="chore(dotfiles): update $(date +'%Y-%m-%d %H:%M:%S')"
git commit -m "$COMMIT_MSG"
git push
echo "Changes pushed with commit: $COMMIT_MSG"
else
echo "No changes to commit."
fi
save-dotfiles.sh - For quickly saving local changes:
#!/bin/bash
set -e
cd "$(chezmoi source-path)"
echo "Applying any staged local changes..."
chezmoi apply
echo "Saving to Git..."
if [ -n "$(git status --porcelain)" ]; then
git add .
git commit -m "chore(dotfiles): update $(date '+%Y-%m-%d %H:%M:%S')"
git push origin main
echo "✅ Dotfiles pushed."
else
echo "📁 No changes to push."
fi
Chezmoi templates allow me to have different configurations based on the machine:
# .chezmoi.toml.tmpl
{{- if eq .chezmoi.hostname "work-laptop" }}
[data]
email = "work@company.com"
git_signing_key = "work-key-id"
{{- else }}
[data]
email = "personal@email.com"
git_signing_key = "personal-key-id"
{{- end }}
One of the most powerful combinations is using Chezmoi with Homebrew’s Brewfile for complete package management. I manage my entire software stack through a Brewfile
that Chezmoi tracks and applies automatically.
# Brewfile managed by chezmoi
tap "homebrew/bundle"
tap "homebrew/cask"
# Essential CLI tools
brew "chezmoi"
brew "git"
brew "neovim"
brew "tmux"
brew "fzf"
brew "ripgrep"
brew "bat"
# Development tools
brew "node"
brew "python"
brew "go"
# Applications
cask "visual-studio-code"
cask "docker"
cask "iterm2"
When setting up a new machine, Chezmoi can automatically run brew bundle install
to restore my entire software environment. This means not only are my configurations synced, but all my tools are automatically installed too!
For a deep dive into mastering Homebrew and Brewfiles, check out my detailed guide on managing development environments with Homebrew.
Sensitive data stays secure but accessible:
# Store encrypted secrets
chezmoi add --encrypt ~/.ssh/config
# Templates can use encrypted data
{{- if hasKey . "github_token" }}
export GITHUB_TOKEN="{{ .github_token }}"
{{- end }}
Automate additional setup tasks:
# run_onchange_install-packages.sh
#!/bin/bash
# This runs whenever the package list changes
{{ if eq .chezmoi.os "darwin" -}}
brew bundle install --file ~/.config/homebrew/Brewfile
{{ else if eq .chezmoi.os "linux" -}}
sudo apt update && sudo apt install -y bat fd-find ripgrep
{{ end -}}
Here’s my typical day with Chezmoi:
chezmoi update
chezmoi init && chezmoi apply
and I’m readyThe most significant change is how seamlessly I can switch between machines:
Chezmoi didn’t just solve my dotfile management problem—it transformed how I think about development environments. The confidence that comes from knowing my configurations are versioned, backed up, and instantly deployable has made me more productive and more willing to experiment.
If you’re still manually managing dotfiles or using a basic Git repository, I can’t recommend Chezmoi enough. The initial learning curve is minimal, but the productivity gains are substantial.
The next time you set up a new machine, instead of spending your weekend configuring everything, you could be coding within minutes. That’s the power of proper dotfile management with Chezmoi.
Ready to revolutionize your own workflow? Check out Chezmoi’s documentation and start your journey to configuration nirvana.