Organising & Synchronising my Dotfiles
Dotfiles are configuration files that hold the settings for applications, such as vim, and are usually located in your $HOME directory. These files allow you to optimise your workflow by customising your development environment. However, as the number of dotfiles grows, keeping them in sync between the different machines that I use has become an increasing problem. Therefore, this article discusses my solution to keeping my dotfiles organised and syncronised between my machines.
A quick Google search results in many solutions to this problem being returned. These solutions generally range from writing your own shell scripts to using open-source projects. dotfiles.github.io provides a large list of available tools, frameworks, and examples to help with your development.
I decided to avoid writing my own script as this would have involved a lot of development. Therefore, I looked for a project that could handle my dotfiles for me in a simple and elegant way. Out of the large number of available projects, I narrowed my search to a small set of the most popular: homesick; homeshick; rcm; and, yadm.
Homesick immediately stood out to me due to its name, which perfectly describes the feeling I get when I use a machine that doesn’t have my configurations; frustration, annoyance, and a desire to return to my own environment when the machine doesn’t respond in the way I expect. However, I quickly moved on from homesick as it is written in ruby, which can be difficult to manage with macOS systems.
Homeshick provides a shell implementation of homesick, avoiding the complexity of managing ruby. However, the install was still not as elegant as I would like, as it requires adding functions to my config.fish file.
Looking at rcm, this program was given good reviews by several sources and, therefore, I decided to take a look. However, the documentation for the project was not easy to read, and installing not clearly defined. While I could have setup rcm if I spent more time looking at it, this was more than I wanted to.
Next in line was yadm. With the name standing for “yet another dotfiles manager”, it was openly admitting to being another manager that was adding to the already huge pile of other available managers. I was hoping this meant it would improve on what the other projects lacked, simplicity and elegance. The documentation featured a basic design, but, complex enough to appropriately organise and quickly convey the required information to setup yadm. Additionally, yadm is based on git, meaning I already knew the basics. Therefore, I decided to try yadm and see what happens.
Setting up yadm
To setup yadm, first I had to install it on my machine, which runs macOS. A brew installation is available, so I ran the following:
brew update
brew install yadm
Since I haven’t previously setup yadm, I created a new instance:
yadm init
This created a new folder ~/.config/yadm
with a new git instance. From
here, I could add my current dotfiles to yadm, like so:
yadm add .hyper.js
yadm add .vimrc
yadm add .config/fish
yadm commit
Now that my dotfiles are organised, it’s time to setup the synchronisation. Firstly, I setup a GitHub repository called dotfiles, and then set yadm to use that as a remote repository:
yadm remote add origin https://github.com/jonathanstaniforth/dotfiles
yadm push -u origin master
Setting up yadm on additional machines
Now that the initial setup of yadm is complete, I now need to setup yadm on my other machines. This part is simpler since most of the work was done in the initial setup. To start, I installed yadm on my Ubuntu machine:
sudo apt update
sudo apt install yadm
Next, I cloned the dotfiles repository using yadm:
yadm clone https://github.com/jonathanstaniforth/dotfiles
Now my dotfiles can be synchroised using yadm pull
.