Manage Your Configs with vcsh

Now that you've got your mr repo cloned, you'll want to go in and edit the files to point to your setup. The control files for mr live in ~/.config/mr/available.d, so go to that directory:


bill@test2:~/.config/mr/available.d$ ls
mr.vcsh  zsh.vcsh

Rename the zsh.vcsh file to vim.vcsh, because you're working with vim, and change the repository path to point to your server:


bill@test2:~/.config/mr/available.d$ mv zsh.vcsh vim.vcsh
bill@test2:~/.config/mr/available.d$ vi vim.vcsh
[$HOME/.config/vcsh/repo.d/vim.git]
checkout = vcsh clone git@gitserver:vim.git vim

Also, edit the mr.vcsh file to point to your server as well:


bill@test2:~/.config/mr/available.d$ vi mr.vcsh
[$HOME/.config/vcsh/repo.d/mr.git]
checkout = vcsh clone git@gitserver:mr.git mr

The mr tool relies on symlinks from the available.d directory to the config.d directory (much like Ubuntu's Apache configuration, if you're familiar with that). This is how mr determines which repositories to sync. Since you've created a vim repo, make a symlink to tell mr to sync the vim repo:


bill@test2:~/.config/mr/available.d$ cd ../config.d
bill@test2:~/.config/mr/config.d$ ls -l
total 0
lrwxrwxrwx 1 bill bill 22 Jun 11 18:14 mr.vcsh -> 
 ↪../available.d/mr.vcsh
bill@test2:~/.config/mr/config.d$ ln -s 
 ↪../available.d/vim.vcsh vim.vcsh
bill@test2:~/.config/mr/config.d$ ls -l
total 0
lrwxrwxrwx 1 bill bill 22 Jun 11 18:14 mr.vcsh -> 
 ↪../available.d/mr.vcsh
lrwxrwxrwx 1 bill bill 23 Jun 11 20:51 vim.vcsh -> 
 ↪../available.d/vim.vcsh

Now, set up mr to be able to sync to your git server:


bill@test2:~/.config/mr/config.d$ cd ../..
bill@test2:~/.config$ vcsh enter mr
bill@test2:~/.config$ ls
mr  vcsh
bill@test2:~/.config$ git add mr
bill@test2:\~/.config$ git commit -m 'Initial Commit'
[master fa4eb18] Initial Commit
Committer: Bill Childers [bill@test2.home]
3 files changed, 4 insertions(+), 1 deletion(-)
create mode 100644 .config/mr/available.d/vim.vcsh
create mode 120000 .config/mr/config.d/vim.vcsh
bill@test2:\~/.config$ git remote add origin git@gitserver:mr.git
fatal: remote origin already exists.

Oh no! Why does the remote origin exist already? It's because you cloned the repo from the author's repository. Remove it, then create your own:


bill@test2:~/.config$ git remote show
origin
bill@test2:~/.config$ git remote rm origin
bill@test2:~/.config$ git remote add origin git@gitserver:mr.git
bill@test2:~/.config$ git push -u origin master
Counting objects: 28, done.
Compressing objects: 100% (21/21), done.
Writing objects: 100% (28/28), 2.16 KiB, done.
Total 28 (delta 2), reused 0 (delta 0)
To git@gitserver:mr.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.
bill@test2:~/.config$ exit

That's it! However, now that mr is in the mix, all you need to do to set up a new machine is do a vcsh clone git@gitserver:mr.git mr to clone your mr repository, then do an mr up, and that machine will have all your repos automatically.

Conclusion

vcsh is a very powerful shell tool, and one that takes some time to adapt your thought processes to. However, once you do it, it makes setting up a new machine (or account on a machine) a snap, and it also gives you a way to keep things in sync easily. It's saved me a lot of time in the past few months, and it's allowed me to recover quickly from a bad configuration change I've made. Check it out for yourself!

Setting up a Remote Git Repo

A quick note on setting up a remote git repo: you'll need to set up passwordless authentication using SSH keys (see Resources for more information). Once you have that going using a "git" user, you simply need to create a git repo as the git user. That's done easily enough, just run the command:


git@gitserver:~$ git init --bare vim.git
Initialized empty Git repository in /home/git/vim.git/

Your bare repo will be ready for your vcsh client to check in stuff!

Resources

vcsh Home Page: http://github.com/RichiH/vcsh

mr Home Page: http://joeyh.name/code/mr

vcsh Background Slides: https://raw.github.com/RichiH/talks/slides/2012/fosdem/vcsh/fosdem-2012-vcsh-talk.pdf

How to Set Up Your Own Git Server: http://tumblr.intranation.com/post/766290565/how-set-up-your-own-private-git-server-linux

Set Up Passwordless SSH Key-Based Authentication: http://askubuntu.com/questions/46930/how-can-i-set-up-password-less-ssh-login

______________________

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

Comments

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.

[1] https://github.com/justone/dfm
[2] https://github.com/jbernard/dotfiles
[3] https://github.com/technicalpickles/homesick
[4] https://github.com/mike-burns/rcm

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: http://stackoverflow.com/questions/1960799/using-git-and-dropbox-togethe...

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix