I like to have a reproducible development environment.
It comes in handy in a variety of situations: changing Linux distributions, moving to a new computer, setting up a desktop the same way my laptop runs, etc.
Part of making the development environment reproducible is having a way to backup and restore its configuration files. The way I do all of that that is quite simple.
I keep all of my config files in a directory named
dotfiles, which is checkout out in Git so that I can revert changes if need be. Here are some of the files from
.asoundrc .bashrc .config .gitconfig .local .npmrc .profile .ssh .Xdefaults .xinitrc
I need a way to restore those files, right?
For that, I have a little script that will make symlinks to where the system will actually look for the configuration files. For instance,
~/dotfiles/.bashrc gets symlinked to
~/.bashrc because that’s where Bash looks for this file.
Here’s that little helper script:
#!/bin/bash cd dotfiles for f in `find . -type f | sed 's#^./##'`; do # create the directory in which to put the config file's symlink echo -n mkdir $HOME/`dirname $f` read mkdir -p $HOME/`dirname $f` # create the symlink echo -n ln -sf $HOME/dotfiles/$f $HOME/$f read ln -sf $HOME/dotfiles/$f $HOME/$f done cd ..
When I run this script, it shows me what it is about to do, asks for confirmation and then creates the symlink where it should be.
Simple enough and low maintenance.