The .bashrc
lies at the heart of most Linux people, but since Git Bash‘s come to Windows, I don’t see why we should be left out?
This article sketches a simple way of keeping your data in the cloud, such that a minimum is needed to get your favourite bash-setup on a new system!
Why would I want to do this?
Well, you might have a config you know you always want. Personally I’d like the bash to always start or capture my ssh-agent, and I don’t want to edit my .bashrc
and tell my computer that, every time I format it, so I’ve added the code from https://help.github.com/articles/working-with-ssh-key-passphrases/ to my .bashrc
and distributed that. So now I only need to tell my computer to actually use the distributed file.
The Setup
First of all, you need a cloud provider, I’m just using Dropbox for this, but you can really use anything you’d like.
- Create the distributed global config
- Go to the cloud-folder where you want to keep your configs,
- somewhere like
D:/Dropbox/config
- create a file called
.bashrc
inside it, - you might have difficulties with this on a Windows system, but
$ cd /D/Dropbox/configs
, and$ vim .bashrc
will work tremendously, (after you’ve created the config folder of course.)
- Inhere, paste your settings, for now it can just be
echo ".bashrc loaded"
- Create the distributed local config
- create a file called .bash_profile in the same folder
- Inhere, you paste the following
if [ -f /D/Dropbox/config/.bashrc ]; then . /D/Dropbox/config/.bashrc fi
- Save it. This will
- Check whether the
.bashrc
file exists, and - Source it, if it does, i.e. load it in the bash.
- Check whether the
- Overwrite your local config with the distributed local config
- e.g. run the command,
$ cp /D/Dropbox/config/.bash_profile ~/.bash_profile
(You might wanna check if the~/.bash_profile
file exists already..), and
- e.g. run the command,
- Restart Git Bash
If you’ve carried out the steps correctly, you should see “.bashrc loaded” when it starts!
So what have we done?
- Created a distributed global config file,
.bashrc
, in Dropbox,
– so we can make changes that are synchronized with all our computers! - created a distributed local config file,
.bash_profile
, in Dropbox,
– so we have an “include .bashrc” template, we can easily copy - overwritten our actual local config file with the distributed local config file.
– actually started using the distributed.bashrc
file on our system.
Q. This seems like a lot of steps, why is this smart?
A. Well, the next time you get a new computer, you only have to carry out the last step above. (Given you’ve installed Dropbox of course….)
Q. But the last step is still a manual step! Why should 1 be better than 3 small steps if I have to spend 10 minutes setting it up, just to save 2 minutes when I’m using it?
A. Seriously?.. Throw the copy-code in a post-format-script.sh and your computer configures automatically. Anything else?
Q. This is genious! Wait, can I do this with other stuff as well?
A. Sure! Personally I’ve made my own Hub.Docker-like setup with Dropbox/Google Drive, selective-sync and portable apps. But that’s another story! – and also an unnecessary workaround since, Docker has now come to Windows. But for a time, it was actually pretty cool!
1 Comment