Surely, this can be achieved with a version control system like git, but I wanted something even easier, more automatic and straightforward. Since the cloud is the word of the day, wouldn't it be cool to have all my settings and scripts synchronized automatically with some cloud service? I happen to prefer Dropbox by far for a variety of reasons. So I gave it a try and found out it's trivial to reach the goal. Let's assume for the sake of simplicity that all you want to have available in all your machines, always up-to-date, is ~/.bash_aliases. These are the only required steps to get it done:
- Install Dropbox. Let's assume the default target directory ~/Dropbox.
- Create a folder inside it, say home, that relates to your user home directory:
- Make sure Dropbox is set up to synchronize ~/Dropbox/home
- Move your Bash configuration to the synchronizable space (i.e. your private cloud). You probably want to rename it so that it doesn't contain the initial dot and stays hidden:
mv ~/.bash_aliases ~/Dropbox/home/bash_aliases
- Create a symbolic link to this new file from your home directory, and have Bash think it's fetching the configuration from its usual place:
ln -s ~/Dropbox/home/bash_aliases ~/.bash_aliasesThat's it. To make it even cooler, I've created a script that performs all the moving and symbolic linking for all files I wish to have synchronized at all times, everywhere. Then, the only task I need to manually repeat every time I add a new machine to my context is the very first one, the installation of Dropbox, making sure that the folder home will be synchronized. All that is missing is running the said script in the end. The script is obviously in the cloud too, in my synchronized ~/bin -> ~/Dropbox/home/bin folder. This works wonderfully for me, I hope you find it useful too.