Configuration sharing with Dropbox, Part 3: Bash
Introduction
In this article, I will explain how you can easily share shell scripts between your workstations. Some of these scripts, such as convenient aliases or a git color prompt script, have to be run each time you start your shell; others only have to be accessible from the PATH. Both cases are covered by this trick.
But first, you should read Part 0, if you haven’t done so already.
One-time set-up
- Create a folder called
bash
inside your~/Dropbox/config
. - Create two subfolders:
scripts
andsession
.scripts
will contain the scripts that need to be on the PATH;session
will contain the scripts that have to run each time you open up a terminal. - Create the
run.sh
file in~/Dropbox/config/bash
. (Indeed; it shouldn’t be inscripts
orsession
!) Make it executable. Its contents should be as follows:
This file will iterate over all the files in the given directory; in this case, ~/Dropbox/config/bash/session/*
, and execute them.
- Finally, create a file called
add-scripts-to-path.sh
in the~/Dropbox/config/bash/session
folder. Again, don’t forget to make it executable. It should contain the following one-liner:
… which is how ~/Dropbox/config/bash/scripts/
ends up on the PATH.
Per computer set-up
On each computer, you need to add the following line to the end of your
~/.bashrc
to make it all work:
Don’t forget the dot! It won’t work without it. And that’s all!