Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|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
up vote 15 down vote accepted

~/.bash_profile

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

~/.emacs

(load "~/Dropbox/Emacs/.emacs")
share|improve this answer
1  
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

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
share|improve this answer

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.

share|improve this answer

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
share|improve this answer

Also check out "homeboy" for general development machine sync'ing and updating: https://github.com/preston/homeboy

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .