Whatever happened to dotfiles?
Back in the 2010’s there was a huge trend around publishing your dotfiles on GitHub.
The idea was to take the files which configure the behaviour of user applications and preferences like for your shell configuration (i.e. the files with a “.” prefix in your home directory, aka dotfiles) and publish them on GitHub for others to learn from and even use.
It’s tough to trace the origins of publishing dotfiles because the idea of sharing your bashrc/zshrc/etc files predates even GitHub itself. But circa 2010 an early GitHub employee, Zach Holman, published his aptly named dotfiles repo.
Of course, the concept of sharing dotfiles as-is had one major flaw: folks sometime store sensitive material in their dotfiles, such as env variables containing secrets. It was only a matter of time before tooling was created to help sanitise files before sharing, and later to help templatise those files so the published versions could remain the source-of-truth. Personally, I prefer to keep my dotfiles repo private, but at times will manually review and publish excerpts for others.
Within a few years of Zach Holman’s first repo appearing, GitHub published a dedicated site (circa 2013) to inform folks about this trend, and common repos and tools around it.
So ‘what happened to dotfiles’? Turns out, many of us still use tools to manage our dotfiles, and some continue to publish them.
But what’s the best tool to use for managing your dotfiles?
Chezmoi is a free and open source command line tool which will help you manage your dotfiles across multiple machines, storing them in git. What I like most about it is the UX/DX — it feels like an extension to git, rather than a whole new paradigm.
If your machine is set-up with your GitHub SSH key already, you can get a new dotfiles repo going in no time with:
`chezmoi init — ssh (your-github-username)`
I’d highly recommend enabling auto-commit & push using:
`chezmoi edit-config`
and adding the following:
[git]
autoCommit = true
autoPush = true
Then all you need to do to add a new file is type:
`chezmoi add (path-to-file)`
and your dotfile will be committed and pushed to your GitHub repo.
Of course, there’s a lot more to chezmoi than this (my favourite function being `chezmoi diff`!), but doing this as a minimum means when you switch machines you’ll be able to retain all of your config. Easy!