Hi, I am Jürgen. I am a Software Developer and passionate about full-stack web technologies.

Rock your OS X setup with dotfiles

April 13, 2018   Comments
Main image from post

Every software developer has their own selection of tools, frameworks, libraries and helper programs to ease their productivity in daily work-life. For many devs it would be a nightmare to install and configure all their things again in case their computer breaks at some point.

So let’s pray that this will never happen… or dig into dotfiles ;)

What are dotfiles?

If you are a more advanced user of a Unix based OS like Linux or MacOS you have probably already seen those special files with a . in the beginning of their filename. They are not shown by default if you list your files with the standard ls command or view them in a Finder window on a Mac. To put it simply, these files configure and customize installed tools on your Mac (This blog post is targeted for MacOS although many of the things apply to a Linux OS as well). One of the most popular dotfiles are the configuration files for the selected shell like .bashrc (in case of bash) or .zshrc (in case of ZShell). You probably have already adapted one of these files in the past to add you fresh JDK installation to the global PATH variable or your git user along with some aliases to the gitconfig. Fine, so you have already made some experience with dotfiles. However, you are maybe in a situation like I was before digging deeper into the topic. So, keep reading and find out how to actually use dotfiles in a more sophisticated manner.

How to use them?

You would probably laugh at me, if I would answer this question simply with “Put the files into separate folders” but actually there is not much more magic behind it. It’s a matter of structure and organization which make them powerful and enable the further steps described in later paragraphs of this post. By default your dotfiles reside in the root of your home directory where some of them, as the shell configuration or .gitconfig, even have to be to work properly. However, symlinks allow to move your files in a ~/dotfiles folder and reference them from your home directory. Creating such symlink can be done like following:

ln -s ~/.bashrc ~/dotfiles/

The awesome thing with your separate dotfiles folder is that you can now easily manage your configuration files with a VCS. This is exactly what you need when you want to setup a new machine. Lovely colors in the command line prompt or shell aliases which make you super productive can simply be pulled from a repository. If you love playing around with shell programming and happen to have some experience you can start right away crafting your dotfiles and linking them with a script automatically in your home directory. However, I would highly recommend to use the awesome community on github. There are several exceptionally good dotfiles repositories you can get started with. Have a look at dotfiles.github.io for inspiration and fork one that looks appropriate to you. Depending on the particular one they are more or less sophisticated and sometimes put more focus on specific areas (eg web development). All of the repos I browsed provided a bootstrap script which sets up everything (like sourcing configurations in a .bashrc or .zsrc or creating symlinks in your home directory). It’s great because you do not have to do a lot of that grunt work yourself but how you setup the files for the tools of your choice is up to you and your preferences. There is no “one and only” dotfiles project and that’s why those projects are made to be forked and shared back to the community. Throw away things you don’t need, adapt things you want to have differently and add new things. The structure of my dotfiles folder for instance looks like that:

Structure of my dotfiles folder

Automation with Homebrew

Now, that you know how you can get started with your dotfiles project, I want to show you some additional automation thing suitable for MacOS which really impressed me. It’s not directly related to dotfiles in particular but any popular dotfiles repo on github contains it. I am talking about utilizing the automation power of the Homebrew package manager. Although I have used Homebrew before, I did not know that you can specify all your packages in a file and install them on demand by a simple brew bundle.

An example for such a Brewfile could look like shown in the code snippet below.

cask_args appdir: '/Applications'

tap 'homebrew/bundle'
tap 'caskroom/cask'

brew 'rbenv'
brew 'tig'
brew 'mysql'
brew 'nvm'
brew 'wget'
brew 'nginx'

cask 'google-chrome'
cask 'slack'
cask 'evernote'
cask 'spotify'
cask 'docker'
cask 'intellij-idea'

As shown in the example, even installing large binaries with the Homebrew-Cask extension can be done easily. Instead of doing that repetitive task of downloading and installing every application manually, a ./bootstrap execution in the Terminal is sufficient and after enjoying your Coffee everything is setup as you want it.

As a final note, I want to warn you from blindly executing the bootstrap script from any dotfiles project. Please make yourself familiar with it before to prevent any unwanted action to your machine. Better delete more things you probably won’t need when you are just starting out and add to your project later on what you need.


I hope I could convince you that managing dotfiles explicitly makes sense. First of all you have your complete configuration setup organized in a central place which makes it tidier and easier to maintain. Secondly, dotfiles let you automate things you maybe have not even thought of before. I could setup my fresh OS installation of my Macbook just by executing the bootstrap script and it was an order of minutes instead of hours or even longer. By the way, feel free to fork my dotfiles to get started. It is based on the outstanding work of Zach Holman with some custom manipulations. Reach out to me if you have any questions, comments or improvement suggestions.