The Ultimate Dotfiles Management Tool
Written by Guglielmo Bartelloni
Managing dotfiles is frustrating, moving files manually is tedious and using other techniques like symlinking files is not comfy. And how about syncing your files across machines? Use a git bare repo? Use Syncthing? Too much hassle.
What if there is a better, less error-prone way to manage your dotfiles (even with encryption)?
Meet Chezmoi!
Chezmoi
When I discovered this tool I was amazed, it solves so many problems that you quickly encounter when you try to implement a dotfiles manager yourself.
Citing from the docs:
chezmoi provides many features beyond symlinking or using a bare git repo including: templates (to handle small differences between machines), password manager support (to store your secrets securely), importing files from archives (great for shell and editor plugins), full file encryption (using gpg or age), and running scripts (to handle everything else).
It’s cross-platform of course and you can install it with your favorite package manager.
For me, the most notable strengths of the tool are:
- Idempotent Operation: Chezmoi operates idempotently, meaning that running the same command multiple times produces the same result, ensuring predictability and reliability in configuration management.
- Extensibility: Chezmoi’s plugin system allows users to extend its functionality by integrating with external tools or writing custom scripts to automate tasks further.
- Version Control Integration: Chezmoi seamlessly integrates with popular version control systems such as Git, allowing users to track changes to their dotfiles and collaborate with others effectively.
Chezmoi manages your files like a database and acts as a single point of truth, so you add a file with:
chezmoi add ~/.zshrc
and whenever you want to edit the file you have to use:
chezmoi edit -a ~/.zshrc
this will open your $EDITOR to edit your file and once you save it will be automatically synced to your file (that’s what the -a option does).
If you want to push the changes to github simply do:
chezmoi cd
to navigate to the chezmoi dir and use the common git commands (git commit, git push).
This is the simple setup but if you want to customize it to your liking there are a lot of features, for example I use the encryption feature with some files like ssh keys that I want to sync but without them being public.
If you want to use this feature you need “age” or “gpg” and you have to add them with the “ — encrypt” flag.
Conclusion
In the world of dotfiles management, Chezmoi stands out as a powerful and elegant solution that simplifies the complexities of configuration management. With its intuitive interface, version control integration, and cross-platform compatibility, Chezmoi empowers users to take control of their computing environments effortlessly.
Whether you’re a seasoned developer, system administrator, or casual enthusiast, Chezmoi provides the tools you need to organize, synchronize, and deploy your dotfiles with confidence.