Chris Sainty

A technical blog covering full-stack web development.

twitter | github | stackoverflow

Beginners guide to dotfiles

I recently received a new Mac. Before setting it up though I wanted to investigate automation to help speed up the process and to re-use config between machines.

I am still somewhat of an OSX/nix beginner. I had heard of dotfiles and seen the GitHub page but it still wasn't really clear to me what these repositories contained and how they helped.

To help anyone in a similar position, here is what I have learned.

Let's start with the code in this repo https://github.com/mathiasbynens/dotfiles.

I will break the contents down in to three groups.

1. The dotfiles

Most of the files in the repo start with a . eg .aliases. These files each provide configuration values for various applications you are running, including your shell / command line. You simply place these in your home folder ~/ and the OS takes care of the rest.
.bash_profile is a special script that runs to configure the command line and can set environment variables, aliases etc. The script provided here splits those in to seperate files, but ultimately just calls them all - see https://github.com/mathiasbynens/dotfiles/blob/master/.bash_profile#L7.
By contrast, a file like .gitconfig is seen whenever you run git commands, and is used to configure your default git settings.

2. Sync and automation

bootstrap.sh does two simple things. First it pulls from github to ensure you have the latest copy of your configuration files. Then it copies them to the home folder. As easy as that is makes sures your config is all up to date.

3. One-time setup

brew.sh and .osx are special scripts desiged to be run as needed. brew.sh simply uses Homebrew to install tooling, and .osx sets OSX level config such as keybindings.

Wrapping Up

Once you understand the underlying tech, you start to see how simple these ideas are and how useful it is to be able to sync config between your machines so simply.

Hopefully this quick intro can save you some time.