--- tags: - Documentation - Bookstack - Notes --- # Chezmoi Guide # Guide **chezmoi** is a powerful, go-anywhere tool for managing your dotfiles across multiple machines. Unlike simple symlinking, it treats your configuration as a source-controlled project, allowing you to manage secrets, use templates for different OSs, and keep everything in a Git repository. Now, just remember to always edit your dotfiles templates. Chezmoi give you some helpers: chezmoi cd # will cd you to the dotfiles repo directory to edit files, or use; chezmoi edit ~/.zshrc # will open the template in your editor Whenever you change the template or the data file, just update everything: chezmoi update push the changes to your repo: chezmoi cd git add . git commit -m "Update dotfiles" git push If you create new dotfiles, let's say you started to use Fish, then don't forget to add it to Chezmoi like this: chezmoi add --autotemplate ~/.fishrc You can use the convenience script to install the dotfiles on any machine with a single command. Simply run the following command in your terminal: export GITHUB\\\_USERNAME=mmcfetridge1969 sh -c "$(curl -fsLS get.chezmoi.io)" -- init --apply $GITHUB\\\_USERNAME Apply will install all the dependencies and add files to your $HOME. chezmoi apply Update - From time to time, start the update simply with: chezmoi diff chezmoi update ## 1. Getting Started To begin, you’ll need to initialize your local state. This creates a hidden directory (usually `~/.local/share/chezmoi`) where the "source" versions of your files live. - **Initialize:** `chezmoi init` - **Add a file:** `chezmoi add ~/.bashrc` - *This moves the file's logic into the source directory and leaves the original file in your home folder untouched.* - **Edit a file:** `chezmoi edit ~/.bashrc` - *This opens the source version in your default editor ($EDITOR).* ## 2. The Core Workflow Once you have added files, you need to manage the synchronization between your **source state** (the repo) and your **destination state** (your home directory).
| **Command** | **Action** |
| `chezmoi diff` | See changes between your source state and your actual home files. |
| `chezmoi apply` | Push changes from your source state to your home directory. |
| `chezmoi cd` | Launch a shell in the source directory (great for Git commits). |
| `chezmoi update` | Pulls the latest changes from your repo and applies them in one go. |