3.2. Dotfiles#

If you followed my previous posts, you may find in your ${HOME} directory several files starting with a dot, or dotfiles: .gitconfig for your git configuration, .zsh for you zsh configuration, and .p10.zsh if you tried Powerlevel10k.

Of course, there are probably a lot of other dotfiles from

  • your editor or your terminal (.vimrc, .bashrc, etc.),

  • software programs or libraries you use (I have one for iTerm2 and matplotlib for example).

This is not an exhaustive list, but ${HOME} is the place where user configurations are usually stored in plain-text files.

3.2.1. The goal#

Since all these dotfiles are just plain-text files, a natural idea is to save them, or to version them, to actually back up your settings, sync them across multiple machines and be able to deploy them quickly. This is particularly useful when getting a new computer, using a remote computer, or for some other reasons we will see in a later post. 😉

That is why, when talking about dotfiles, people refer to a git repository that stores all these dotfiles, but also contains some scripts (sometimes called bootstrap) to set everything on a new environment:

  • install the dotfiles into ${HOME},

  • install utilities (for example, a plugin manager for zsh or an enhanced prompt as we have seen in with zsh),

  • install libraries (via Homebrew and processing a .BrewFiles on macOS for example),

  • etc.

And it needs to be easy to deploy, with a one-line command in the terminal for example.

3.2.2. How-to#

As always, there are lots of possibilities to achieve this, and it also depends on your particular needs, so you need to try and fail to find what is the best for you.

That being said, there exists several tools to do all the heavy lifting. At the moment, I use YADM which I find easy to use and well-maintained. I refer to its documentation for more details, but it really feels like using git in your ${HOME}, which could be cumbersome to do directly. Besides, it offers the possibility to run a script, called boostrap, when cloning a repository via YADM. You can use it

  • to set up your zsh or git (the git config options),

  • or to install packages using your system/language package manager

  • or to set up your OS settings. In particular, for macOS you can look at this file.

Warning

Beware, you should not store confidential information on a remote repository (email, password, …). YADM and tools like such offer some encryption features, use them or do not take any risk.

There exists a lot of tools to manage dotfiles, they all have their own strategy (wrapping git, using symlinks, …). The best thing to do is to try by yourself and check which one fits best your needs, here is a non-exhaustive list.

3.2.3. References#

3.2.3.1. Lists of dotfiles#

  • An unofficial guide to dotfiles

3.2.3.2. Other tutorials/introductions#