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
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
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 ↪/home/bill/.config/vcsh/repo.d/vim.git/
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.
|Alice, the Turtle of the Modern Age||Mar 07, 2014|
|Using Django and MongoDB to Build a Blog||Mar 05, 2014|
|What virtualization solution do you use/manage at work?||Mar 04, 2014|
|Our Assignment||Mar 04, 2014|
|March 2014 Issue of Linux Journal: 20 Years of Linux Journal||Mar 03, 2014|
|Have Resume - Will Travel||Feb 28, 2014|
- You have to be careful there
1 week 4 days ago
- Wonder when LJ is going to
1 week 5 days ago
- Puerto Rico Free Software
1 week 6 days ago
2 weeks 9 hours ago
- I hate voice commands
2 weeks 23 hours ago
- usabilty --- AGAIN with this nonsense
2 weeks 1 day ago
- Don't make excuses
2 weeks 1 day ago
- Sorry to let you know, but
2 weeks 1 day ago
- Ridiculous statement. Not a
2 weeks 2 days ago
2 weeks 2 days ago