I've got two computers, one at work and one at home. The work one has a VM running Arch, and the home one runs Arch natively. The work one usually stays at work, but push a lot of stuff back and forth with git, so when I work on something at one place, I can pick up where I left off in another.
One thing I do quite a lot is tweak config files, for things like Vim, ZSH, i3, blah blah blah, and I'm getting real sick and tired of having to remember what I did the night before to keep the next machine I'm using up to speed!
I know this is a job for Git, but how should I manage this? For instance, I have a bunch of dot files all over my home directory in different sub-directories. I would need to not only keep track of the changes, but also manage the location of those files relative to where they are in any repository that I could create.
The other thing is, some of these dot-files would require software to be installed....So, take i3 for example: I installed i3 on my home machine and got it to my liking with it's config file...But, simply pulling the dot-files when I get to work won't make much sense, because the work laptop wouldn't have i3 installed on it! I would have to remember to install such-and-such as well. Another good example of this is python modules...Sometimes, I'll get something done and forget the exact names of the modules I had to install as python dependencies to get it running. In this case, simply pulling the config files is only half the story...I would need a script or something to make sure that the backend for these config files is up to date and in place.
I know this is a less than specific question that people like to see on here, but I also feel as though this issue has a tribal-knowledge amount of documentation available for how top quality Unix/Linux users handle this seemingly realistic administration task. Everyone suggests something very different, and most issues seem related to recovering from a full system failure as opposed to simply staying up to date between two frequently used machines.
2 Answers
I would recommend using stow following this guide.
With this approach all the dotfiles will be in one folder, which can be version-controlled/synced. It creates symlinks, so that the dotfiles can easily updated.
As for installing the software which is needed, the simplest way would be to just create a bash script or file with notes what to do alongside the config:
/home/user/ dotfiles/ bash/ .bashrc .bash_profile .bash_logout i3/ .config/ i3/ [...some files] i3.install.sh
$ cd ~/dotfiles
$ stow bash
$ ./i3.install.sh
$ stow i3 1 I solved this by placing (most of) my dot files in ~/dotfiles, which is a git repo that I regularly push to github.
In this repo I also have a script that sets links up at the right location:
#!/bin/bash
for f in $(find -name ".*" -type f); do if [[ -e $HOME/$f ]]; then mv $HOME/$f $HOME/$f.old fi ln $f $HOME/$f
doneSo far, the "right location" is only $HOME, but it's up to you to make the script create links to other places.
I used hardlinks because git saves symlinks as links by default, but I'm sure there is a way to fix it for symlinks.
In a new version, I extended the script to remove interfering config files such as ~/.config/git/gitk. I could just as well have set links there instead of in $HOME.
It sounds like what stow does, it just seemed easy enough to skip involving yet another tool.
I am considering putting my .emacs.d and .xmonad repos as sub-modules in my dotfiles repo... Maybe not worth the hassle though, and I'm not unlikely to forget the --recursive while cloning.