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?

link|improve this question

1  
Clever question! – msanford Dec 21 '10 at 4:33
I can't seem to comment on the (great) selected answer. I don't know if this is something specific to osx/mac but I needed to make a couple of changes for it to work DROPBOX_PROFILE='~/Dropbox/Bash/.bash_profile' if [ -f $DROPBOX_PROFILE ]; then . $DROPBOX_PROFILE fi Should be DROPBOX_PROFILE="$HOME/Dropbox/Bash/.bash_profile" if [ -f $DROPBOX_PROFILE ]; then . $DROPBOX_PROFILE fi Hope that helps. – Jason Jan 26 '11 at 1:45
Just to make it clearer: @Jason's tweaks are to replace the single-quotes with double-quotes and to replace '~' with '$HOME' in the definition of DROPBOX_PROFILE – sprugman Dec 11 '11 at 19:30
feedback

4 Answers

up vote 9 down vote accepted

~/.bash_profile

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

~/.emacs

(load "~/Dropbox/Emacs/.emacs")
link|improve this answer
I personally feel that source is more readable (and googlable) than the dot operator, but it is your answer and so I will not edit it. Other than that, +1 for a good answer. – Hello71 Jan 26 '11 at 1:13
feedback

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.

link|improve this answer
feedback

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
link|improve this answer
feedback

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
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.