Syncing bash profile between computers

I have tons of stuff in my .bash_profile. The problem is, I use ~3 computers very frequently, and I'm tired of having to copy paste my prefs everywhere. Two of them run Ubuntu 10.10, and one runs OSX. I was wondering if there was a way to use Dropbox, to share a single prefs file. Like, when bash starts, tell it to check ~/Dropbox/Bash/.bash_profile ?

Although, could I also tell emacs to look in ~/Dropbox/Emacs/.emacs somehow?


Solution 1:

~/.bash_profile

DROPBOX_PROFILE='~/Dropbox/Bash/.bash_profile'
if [ -f $DROPBOX_PROFILE ]; then
    source $DROPBOX_PROFILE
fi

~/.emacs

(load "~/Dropbox/Emacs/.emacs")

Solution 2:

How about this, which avoids having special config files that source the Dropbox versions?

$ ln -s ~/Dropbox/Bash/.bash_profile ~/.bash_profile
$ ln -s ~/Dropbox/Emacs/.emacs ~/.emacs

Solution 3:

In your regular .bash_profile, just call ~/Dropbox/Bash/.bash_profile.

#.bash_profile
. ~/Dropbox/Bash/.bash_profile # the '.' command runs a file.

Actually, you probably want to call the shared file something else, or at least not make it a hidden file.

Solution 4:

I think this would get what you want, just check to see if the file exists, if so, source it.

in $HOME/.bash_profile

[ -f $HOME/Dropbox/Bash/.bash_profile ] && source $HOME/Dropbox/Bash/.bash_profile