I have created a custom .vimrc and .bashrc in my local machine.
Also I have a couple of vim plugins that I find useful. Now I ssh remote servers to work very frequently. But each time in order to work I need to spend/lose some time copying my local environment so that I can work (i.e. .vimrc etc).
I was wondering is there a way for me to not have to do this but somehow my configuration become available/"visible" in each remote server I ssh?


You can create a git or mercurial repository with your custom scripts e.g. in ~/myscripts. Clone it to where it is needed. Also, add a script to create symlinks to the myscripts directory in your home directory ~/ and maybe a script to pull changes from everywhere and update.

Well, adapt it to your own needs...

  • +1.Interesting.Requires some work in areas I am not really familiar, but seems doable. – user65971 May 23 '13 at 21:34
  • if ssh is already in place, git or mercurial take only a few commands to learn, to get you started. hgbook.red-bean.com or git-scm.com/book. A good tutorial for Mercurial is also hginit.com. – pvoosten May 23 '13 at 21:36

Like pvoosten, i suggest keeping a git repo. I've put an alias into my .bashrc to clone that and then run a script which symlinks the ~/homedir files back to that repo checkout.

It's super quick and dirty, but looks a little like this (feel free to improve - i suggest doing something like an ls ~/repo/home/ | grep -v setup-links.sh dir listing in setup-links.sh to avoid the need for the crappy filePaths=):

You could also make the .bashrc alias use ssh and scp to work remotely on the machine and avoid both steps 2 and 3 below, but it works for me anyhow.

It means you can do:

  1. ssh-copy-id (host) setup password-less ssh
  2. scp .bashrc (host) copy your bashrc over
  3. ssh (host) -A login to the host and forward ssh agent
  4. setuphome does a clone of the git repo, and sets up the links

Obviously don't put your ssh keys into the git repo, or gpg keyring

.bashrc (which is itself in git and after step 4 will become a symlink):

alias setuphome='git clone (your git repo) ~/repo/home && cd ~/repo/home && ~/repo/home/setup-links.sh 2>/dev/null remove ; ~/repo/home/setup-links.sh make 2>/dev/null; cd ~'


if [ "$1" == 'make' ]; then
    echo 'Making links'
    for filePath in $filePaths; do
        grep '/' <<< $filePath >/dev/null && mkdir -p $(dirname $filePath) 2>/dev/null
        ln -s $(pwd)/$filePath ~/$filePath 
elif [ "$1" == 'remove' ]; then
    echo 'Removing links'
    for filePath in $filePaths; do
        unlink ~/$filePath
    echo 'Error, $1 should be "make" or "remove"'
    exit 1


Keep your stuff in a git repo which includes a script for setting things up.

As an example, here are my dotfiles:


And this is the script I run to "install" them:


There are plenty of other repos on GitHub if you just search for "github dot files".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.