How I Manage My Dotfiles

I've had my dotfiles (or rcfiles, or whatever you want to call them) in a GitHub repository for a while now and have really appreciated the consistency across machines that such a setup provides. I started with just my vim files: colorschemes, plugins and rcfiles, but recently, I started work on a unified bash configuration as well. This is how I have everything set up.


Between work machines, home machines and various other servers I've had access to, it's been a pain having a different working environment on each machine, so obviously some unified configuration was in order. A challenge to this, of course, is maintaining different options between my work machines and personal machines: some things needed to be specific to and unshared between each. I accomplish this in two ways:

  1. Things that are shared are kept in the master branch of the repository;
    anything that needs to be environment-specific is kept in a separate branch.
  2. My bash configuration has the option to load local files which can be
    branch-specific or not even kept in git at all.

Vim Configuration

Config files and plugins for vim are laid out like so:

|-- vim/
|   `-- ...
|-- vimrc
|-- gvimrc
`-- ...

It's pretty standard from that point: GUI-specific configuration in my gvimrc, with a few platform-specific options for things like fonts and maximizing the window automatically on Windows:

if has("win32")
   set gfn=Bitstream_Vera_Sans_Mono:h10:cANSI
   au GUIEnter * simalt ~x
elseif has("mac")
   set gfn=Bitstream\ Vera\ Sans\ Mono:h12
elseif has("unix")
   set gfn=Bitstream\ Vera\ Sans\ Mono\ 12

Bash Configuration

My bash configuration all lives in bash_profile; most of it is related to setting up the prompt and environment, obviously. I don't get too fancy with my bash environment, mainly things like setting DISPLAY to the remote SSH host so that I can use X directly without forwarding if I'm on the LAN:

if [ -n $DISPLAY ]; then
   declare -x DISPLAY=`cut -d ' ' -f 1 <<< $SSH_CLIENT`:0.0

I also shorten my username and the hostname of the machine if they're "familiar" enough to save space, and I color my prompt based on a unique (modulo the number of colors available in a plain xterm-color) hash of the hostname. I also display git repo status in my prompt, since I have a tendency to forget to switch branches.

Setting it all up on a new machine

My setup script will symlink all the files I've configured into the right place in the home directory, and will ask the user whether or not to move existing files to FILENAME_old. So, when I log into a new machine, all I need to do is git clone the repository and then run and I'm all set and ready to go.