Managing user configuration files across multiple computers
Solution 1
At the moment, I use a cloned git repo. To keep things simple, the only file that needs to vary between the different machines is .bashrc
. It's nice if there can be just one version of this file that responds differently on different machines. Thus, in my .bashrc
:
if [ $(hostname) == 'host1' ]; then
# things to do differently on host1.
elif [ $(hostname) == 'host2' ]; then
# things to do differently on host2.
fi
This obviously has some limitations (such as that a different technique would be required for .vimrc
or other config files needing customization), but it works fairly well.
Solution 2
I keep a folder at ~/config/
which is a bzr repository. I push/pull the repository between my various computers to sync it up. I have an install script which I use to make symlinks to my home directory:
#! /bin/sh
# link all files to the home directory, asking about overwrites
cd `dirname $0`
SCRIPT_DIR=`pwd`
SCRIPT_NAME=`basename $0`
FILES=`bzr ls --versioned --non-recursive`
cd $HOME
for FILE in $FILES; do
ln --symbolic --interactive $SCRIPT_DIR/$FILE
done
rm $TARGET_DIR/$SCRIPT_NAME
If you want to use git instead of bzr, you can instead use:
FILES=`git ls-tree --name-only HEAD`
(I had to ask SO to figure that out)
EDIT: I don't actually do this anymore, now I have a dotfiles repo on github, with a nice rake install script that someone else wrote.
Solution 3
With CfEngine you can manage config files across machines and do also many more things! The learning curve is maybe a bit high but worth it if you have to manage/update/maintain a pool of computers running linux regularly.
Solution 4
If you use git, you could define an "origin" repo to be the master; and then do a clone on each computer you work. you could use a branch for every computer to have your set of config files.
Solution 5
Here are some dotfile managers:
Comments
-
Peter almost 2 years
I commonly work on multiple computers. I have various configuration files, eg,
.bashrc
,.gitconfig
,.irbrc
,.vimrc
and configuration folders, eg,.vim/
that contain valuable customizations. Sometimes I want small variations in configuration between the different computers.I want to use version control to manage these different files.
- do others use version control to manage their configuration files?
- what are some hints that might make this easier?
- what's the most elegant way of dealing with variations between the computers?
- I'm comfortable with
git
; any other suggestions?
-
Rob Wilkerson over 14 years+1. I use Dropbox too. I also move across multiple operating systems, so most of the config files in Dropbox have an extension to denote the OS on which they were created. If both environments are the same, I can link to the same file regardless of the extension. For example, I have a .profile symlink that points to ~/Dropbox/config/bash/profile.osx. On my linux box, it points to ~/Dropbox/config/bash/profile.lin.
-
user89021 over 14 yearsI use slack a lot. It is lightweight and fast and does not get in the wayand. Works very reliable here.
-
Bash over 12 yearsOr puppet, chef, bcfg2 and others.
-
Shuo almost 11 yearsThank you. the dotfiles repo is very helpful!
-
vaichidrewar over 10 yearsYou can have .bashrc.local file on each machine and you can source that .bashrc.local through common .bashrc file. .bashrc.local will have customization specific to that machine (like color).
-
meder omuraliev over 10 yearsWhat's the benefit of the rake install script versus your old bash script? And is there a difference between you having a bzr repository versus a dotfiles repo on github? It sounds like the same solution except you're just using git vs bzr, and a different install script now?
-
yPhil over 9 yearsLike meder, I wonder what the benefits are, I tried your rake script in a fresh user install, and apparently it does not know how to update, only install..?