I’m a pretty active command line user and I have shell accounts all over the place. MacBooks, Linux desktop machines, Linux servers, Cygwin on XP, you name it.
How can I keep my shell configuration (.bashrc, .vimrc etc.) in sync across all these machines using the limited tools available across all platforms?
I have been using rsync in a pretty limited manner that involves manually copying some files over when I need them, but I want a standard way for setting up the same basic shell environment across all my machines. Tell me your shell account management strategy.
I have folder on Dropbox with global, per OS, and per machine shell configs:
bashrcis loaded on every machine,bashrc-Linux,bashrc-Darwinare loaded on their respective OSes, and several configs are specific to individual machines. (By the way, Darwin is the name of OS X’s BSD-like kernel.)What ties it all together is the
bashbootstrapfile. It loads each applicable config file in order of increasing specificity, this allows per OS and per machine overrides to have higher precedence. Additionally, we silently skip missing config files; you need not create empty config files for each of your machines to keep the script happy.On a new machine, after installing Dropbox on
~/Dropbox, I move away the default.bashrcand just symlink the bootstrap file in its place instead:Oh, and here are the contents of the
bashbootstrapfile:One final note, this script also provides three convenience aliases for editing your Bash config files without having to remember where they are stored.
editbashrc: Edit the global config file.editosbashrc: Edit the OS-specific config file.editlocalbashrc: Edit the machine-specific config file.I only tested this on Bash, but it could work on other Bash like shells. But, as they say, your mileage may vary.
I made a blog post about this here.