| « 'cuz multiple steps into one is cool :) | Yaks » |
Sun, Jan 29, 2012
![[Icon]](rsc/img/chain_link.gif)
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..
![[Links]](http://geekblog.oneandoneis2.org/skins/112/rsc/img/chain_link.gif)
I'm in the Perl newsletter again. I should try and write about some other language...
21/05/12
Facebook Syndication Error
22/05/12
![]()
I last listened to:
Johann Pachelbel - Canon in D major
Most recent photo:
js.js