Personal dotfiles managed with chezmoi.
chezmoi keeps two copies of your configuration:
- Home directory: the files your applications use, such as
~/.bashrc. - Source directory: this Git repository, normally
~/.local/share/chezmoi. chezmoi stores~/.bashrcasdot_bashrcand~/.configasdot_config.
chezmoi add copies files from home into the repo. chezmoi apply writes the
repo's configuration back to home. Commit and push to back up changes on GitHub;
this repo's chezmoi configuration disables automatic commits and pushes.
On a machine where this repo is already initialized, add an existing file:
chezmoi add ~/.bashrcTo add a directory and its contents instead:
chezmoi add --recursive ~/.config/zedUse home-directory paths with chezmoi; it handles the source filenames for you. Adding a file updates the local repo only. To back it up remotely, enter the source directory and commit the files you added:
chezmoi cd
git status --short
git diff -- dot_bashrc
git add -- dot_bashrc
git diff --cached
git commit -m "chore(bash): back up shell configuration"
git push
exitFor the Zed example, use dot_config/zed in the Git commands and a suitable
commit message. Review newly added files before staging them; git diff does
not show untracked files. chezmoi cd starts a shell in the source directory,
and exit returns to your previous shell.
Edit the repo's copy through chezmoi, using the corresponding home path:
chezmoi edit ~/.bashrc
chezmoi diff ~/.bashrc
chezmoi --dry-run --verbose apply ~/.bashrc
chezmoi apply ~/.bashrcchezmoi edit changes the source file. The application-facing file changes when
you run chezmoi apply. You can also edit dot_bashrc directly in this repo,
then use the same preview and apply commands.
If you already edited ~/.bashrc directly, capture that version in the repo:
chezmoi add ~/.bashrcThen use the commit-and-push steps above to save either kind of update.
git diff shows changes in the repo; chezmoi diff shows what applying the
repo would change in your home directory. Capture home-directory edits before
applying if you want to keep them.
Install Git and curl with your system's package manager. Then install chezmoi with the official installer:
sh -c "$(curl -fsLS https://get.chezmoi.io)" -- -b "$HOME/.local/bin"
export PATH="$HOME/.local/bin:$PATH"
chezmoi --versionEnsure ~/.local/bin is also in your shell's PATH for future sessions.
Set up a GitHub SSH key with access to this repo, then clone it through chezmoi:
chezmoi init git@github.com:eagleusb/dotfiles.gitThis initializes the source directory without applying the dotfiles. Review the changes against the laptop's existing files, then apply them:
chezmoi diff
chezmoi --dry-run --verbose apply
chezmoi applyRestart your shell or affected applications to load their new configuration.
First capture, commit, and push any local changes you want to keep using the steps above. Then pull the latest repo changes, preview them, and apply:
chezmoi git pull -- --rebase
chezmoi diff
chezmoi applyIf Git reports a conflict or the pull fails, resolve it before applying. When you want to pull and apply immediately, use the shortcut:
chezmoi updateSee chezmoi's quick start and daily operations for more examples.