[1+1=2]

OneAndOneIs2

« 'cuz multiple steps into one is cool :)Yaks »

Sun, Jan 29, 2012

[Icon][Icon]My settings, everywhere

• Post categories: Omni, FOSS, Technology, My Life, Helpful

A strength of open-source software is how customisable it is. This is a good thing. However, it has one downside - once you get used to having certain behaviour in place, it drives you nuts to be on another system that has different behaviour.

Of course, you can solve this by copying config files around. But this gets tedious when done by hand if you regularly add new behaviours. My .vimrc and .bashrc in particular change often as I learn more and come up with new features.

What you want is some way of keeping files in sync across many machines. In the old days, you'd have used something like rsync. But personally, I'm a big fan of Git.

So since I've got access to a virtual server these days that I'm not doing much else with yet, and I'm tired of having my settings not being unified, I sat down and set something up. And here's what I did:

On the server, create a repo you can drop the files into:

mkdir personal_files.git
cd !$
git init --bare

On the machine(s) you want these files on, create a repo to hold the files:

mkdir gsync
cd !$
git init

Now, grab the config files you want to share across systems. There's a few ways you can do this. Let's say you want to share your Bash, Screen, and Vim settings. In your ~/.screenrc add the line:

source $HOME/gsync/screen

In your ~/.bashrc add the following:

if [ -f ~/gsync/bash ]; then
    . ~/gsync/bash
fi

And for your ~/.vimrc move the entire file into your gsync directory, rename it to remove the leading '.' and then:

ln -s ~/gsync/vimrc ~/.vimrc

Job done, all your files are now living in your gsync but used by your home directory. Now it's simple to go into your gsync directory, and get the files into your remote repo:

git add .
git commit
git remote add origin ssh://server/home/git/repositories/personal_files.git
vi .git/config

You can probably do this via a git config command, but this is faster for me: Add

[branch "master"]
    remote = origin
    merge = refs/heads/master

..to the bottom of the file. And then,

git push

That gets all of your files uploaded to the repo. You can now create as many repositories on as many other machines as you like, have them all pull from your remote server, and you're never more than a quick git pull away from your latest config options.

Oh, and for when you've updated your Bash settings and don't want to have to log out & log back in to get them to take effect, one alias you might like to add to your shared bash file is:

alias rebash='source ~/gsync/bash

I'm hoping this little setup will make my life a lot easier in future..

2 comments

codeskraps
Comment from: codeskraps [Visitor]
I haven't tried it myself but this seems like a job to be done with Dropbox and let this synch config files between computers.

Firefox for instance can synch a lot of things currently but one thing it doesn't synch between computers is addons. I have the addons folder for firefox link to a folder in my dropbox. Every time I install a new addons a remove one, this gets updated automatically.
02/02/12 @ 11:48
oneandoneis2
Comment from: oneandoneis2 [Member] · http://geekblog.oneandoneis2.org/
I'm not a fan of Dropbox - this system puts everything under my control, on machines I control: It can't suddenly go away or start charging me.
02/02/12 @ 12:48

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
This is a captcha-picture. It is used to prevent mass-access by robots.
Please enter the characters from the image above. (case insensitive)
 

[Links][icon] My links

[Icon][Icon] I'm in the Perl newsletter again. I should try and write about some other language...
21/05/12

[Icon][Icon] Facebook Syndication Error
22/05/12

[Icon][Icon] I last listened to:
Johann Pachelbel - Canon in D major

[Icon][Icon] Most recent photo:
js.js

[Icon][Icon]About Me

[Icon][Icon]About this blog

[Icon][Icon]My LQ profile

[Icon][Icon]My /. profile

[Icon][Icon]My Wishlist

[Icon]MyCommerce

[FSF Associate Member]


May 2012
Mon Tue Wed Thu Fri Sat Sun
 << <   > >>
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      

Search

User tools

XML Feeds

eXTReMe Tracker

Valid XHTML 1.0 Transitional

Valid CSS!

[Valid RSS feed]

powered by b2evolution