Dotfiles
I’ve been thinking about putting my environment configuration files (aka dotfiles) into an SCM.
Several folks have their dotfiles on GitHub (e.g., caarlos0, mathiasbynens, jessfraz). There’s even an unofficial guide to dotfiles on GitHub.
Challenge
IMO, the main decision is how to bootstrap them. I see 3 schools of thought:
- Clone your repo directly to your home directory.
- Clone your repo to a separate directory. Then symlink your files. For example, see caarlo0’s bootstrap.sh, or jessefraz’s Makefile.
- Like #2, clone repo to a separate directory. But then use some tooling to sync config files and scripts to your home directory. For example, see mathiasbynens’s bootstrap.sh.
Approach #1 is not elegant or clean, and can lead to confusion. I’m not going to do that.
Approach #2 has the advantage that you can modify the files directly, test them and commit.
But the disadvantage is it seems messy.
At best, lots of symlinks when you do ls
.
At worst, some scripts might get confused.
Approach #3 is visually and operationally clean. But the disadvantage is that you need to modify the files on the directory for your repo. So there’s friction when editing and testing the files.
Approach
Today, I learned about chezmoi. It is a dotfile manager that uses Approach #3. But they provide tooling to simplify the deployment of the configuration files. It also offers templates which could be helpful. (NOTE: don’t overdo templates or you’ll pay the price. Remember Jinja2 templates on Ansible 😎).
BTW, there are several other utilities to manage dotfiles.