Manage Your Configs with vcsh

If you're anything like me (and don't you want to be?), you probably have more than one Linux or UNIX machine that you use on a regular basis. Perhaps you've got a laptop and a desktop. Or, maybe you've got a few servers on which you have shell accounts. Managing the configuration files for applications like mutt, Irssi and others isn't hard, but the administrative overhead just gets tedious, particularly when moving from one machine to another or setting up a new machine.

Some time ago, I started using Dropbox to manage and synchronize my configuration files. What I'd done was create several folders in Dropbox, and then when I'd set up a new machine, I'd install Dropbox, sync those folders and create symlinks from the configs in those directories to the desired configuration file in my home directory. As an example, I'd have a directory called Dropbox/conf/mutt, with my .muttrc file inside that directory. Then, I'd create a symlink like ~/.muttrc -> Dropbox/conf/mutt/.muttrc. This worked, but it quickly got out of hand and became a major pain in the neck to maintain. Not only did I have to get Dropbox working on Linux, including my command-line-only server machines, but I also had to ensure that I made a bunch of symlinks in just the right places to make everything work. The last straw was when I got a little ARM-powered Linux machine and wanted to get my configurations on it, and realized that there's no ARM binary for the Dropbox sync dæmon. There had to be another way.

...and There Was Another Way

It turns out I'm not the only one who's struggled with this. vcsh developer Richard Hartmann also had this particular itch, except he came up with a way to scratch it: vcsh. vcsh is a script that wraps both git and mr into an easy-to-use tool for configuration file management.

So, by now, I bet you're asking, "Why are you using git for this? That sounds way too complicated." I thought something similar myself, until I actually started using it and digging in. Using vcsh has several advantages, once you get your head around the workflow. The first and major advantage to using vcsh is that all you really need is git, bash and mr—all of which are readily available (or can be built relatively easily)—so there's no proprietary dæmons or services required. Another advantage of using vcsh is that it leverages git's workflow. If you're used to checking in files with git, you'll feel right at home with vcsh. Also, because git is powering the whole system, you get the benefit of having your configuration files under version control, so if you accidentally make an edit to a file that breaks something, it's very easy to roll back using standard git commands.

Let's Get Started!

I'm going to assume you're on Ubuntu 12.04 LTS or higher for this, because it makes installation easy. A simple sudo apt-get install vcsh mr git will install vcsh and its dependencies. If you're on another Linux distro, or some other UNIX derivative, you may need to check out vcsh and mr, and then build git if it's not packaged. I'm also going to assume you've got a working git server installed on another machine, because vcsh really shines for helping keep your configs synchronized between machines.

Once you've installed vcsh and its dependencies, it's time to start using vcsh. Let's take a fairly common config file that most everyone who's ever used a terminal has—the config file for vim. This file lives in your home directory, and it's called .vimrc. If you've used vim at all before, this file will be here. I'm going to show you how to get it checked into a git repository that is under vcsh's control.

First, run the following command to initialize vcsh's git repository for vim:

bill@test:~$ vcsh init vim
vcsh: info: attempting to create '/home/bill/.config/vcsh/repo.d'
vcsh: info: attempting to create '/home/bill/.gitignore.d'
Initialized empty Git repository in 

I like to think of the "fake git repos" that vcsh works with to be almost like chroots (if you're familiar with that concept), as it makes things easier to work with. You're going to "enter a chroot", in a way, by telling vcsh you want to work inside the fake git repo for vim. This is done with this command:

bill@test:~$ vcsh enter vim

Now, you're going to add the file .vimrc to the repository you created above by running the command:

bill@test:~$ git add .vimrc

You're using normal git here, but inside the environment managed by vcsh. This is a design feature of vcsh to make it function very similarly to git.


Bill Childers is the Virtual Editor for Linux Journal. No one really knows what that means.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

used to use tcsh or bash.

tchen752's picture

used to use tcsh or bash. it is really new for me

One of the more frustrating

sollen's picture

One of the more frustrating things about making repairs to your car is when they don’t go quite correctly, and the car fails the first post-repair test drive. Any time you replace parts, you need to put the new parts in so that they fit and function the way your car came from the factory.

برامج مجانية

BBM for iPhone's picture

One comment: You can also set up bare git repos inside the filesystem

This is making me dizzy.

Ventrice Humphrey's picture

Bill, since I consider you *nix royalty. This criticism is difficult for me.
I am very familiar with this issuse. For me, I simplified this problem by maintaining a my configuration files on my server.
New box or reinstall, I just secure copy all the configuration directories to the new box. Simple one commad.

Overly complicated

Pablo Olmos de Aguilera C.'s picture

I found this method a bit too much. Maybe it could prove useful in some kind of "professional" environments, but for one person. And a couple of machines, tools like dfm[1], dotfiles[2], homesick[3] and/or rcm[4] are most than enough and way simpler.

I'm using rcm right now and I think it's the best tool around for this purpose.


Would love to see a

Caleb Cushing's picture

Would love to see a comparative write up on why rcm over the others. do any of these support running scripts on initialization? I've started using VAM for my vim plugins, but I need to grab VAM for it to work.

Hardly Familiar in VCSH

cledwyn's picture

Honestly,I'm not familiar in vcsh but I like to try that.
I should start to follow your steps in vcsh configuration.

Git repos inside the filesystem

vehka's picture

Thanks for a great article, I'll definitely have to check out vcsh. One comment: You can also set up bare git repos inside the filesystem, for example, in the Dropbox (or equivalent) folder, so that they get backed up automatically.

See this post on how it's done: