Protecting Your .bash_profile from Loss
Many developers and regular users frequently use the command line to get things done on their computers. I know I do. As a result, my bash profile is set up very specifically to include libraries and files I use frequently. What would happen if my computer’s hard drive and backup were to go kaput? I would be out of luck, and have to configure that all again.
That’s how it used to be. Now, with the help of Dropbox (or any other cloud storage system that creates a folder on your computer) you can ensure your bash profile stays alive no matter what state your machine is in. This is also handy if you want to use the same bash profile on multiple machines, or make changes to it on the go. Here’s how.
This tutorial assumes you are on Mac OS. It can also be applied to Windows, however the instructions are Mac specific.
- Create a new terminal window, and change the path to your user directory.Use this command:
Copy your .bash-profile to your safe location. For the purposes of this tutorial, I’m putting it in my dropbox, but you can substitute any path you like. Here’s the command:
cp .bash_profile ~/Dropbox/bash_profile
You’ll notice that I didn’t include the dot in front of the bash profile file that I placed into the dropbox. This is necessary because dropbox doesn’t sync files that have are hidden (have a dot in front of their name).
- Delete your old bash profile:
sudo rm .bash_profile
- Link the bash profile in your dropbox back to where the old one used to be:
ln -s ~/Dropbox/bash_profile .bash_profile
Voila! Your bash profile now lives safely and happily in your dropbox. You can follow steps 3 and 4 on another machine if you wish to use the same bash profile in both places.
Enjoy your newly protected and synced bash profile!