Skip to content

.dotfiles - one to rule them all

Posted on:February 5, 2017 at 06:35 PM

Having a repository with a collection of all your dotfiles is the best way to keep your environments synced on multiple machines (i.e. home and work). Having one of these bad boys allows you to set up a new machine in a matter of seconds, installing all your settings, aliases and even programs.

But What is exactly a dotfile?

Quoting Captain Hindsight, a dotfile is a file whose filename starts with a ..

A file starting with a . means that is not a normal file, they don’t have an extension, and in Unix file systems they are hidden. Dotfiles are files usually stored in your ~ and they contain a bunch of settings and configurations. For example, .gitconfig can contain a series of shortcuts you usually use in git, .bashrc can contain a bunch of alias or programs automatically executed once you open your terminal.

One to rule them all

It has been a while since I started messing around with all my dotfiles. My first approach was copying them manually or using Dropbox and symlinks to move and link them across different machines. It was working but it wasn’t the best solution possible, even because I was just copying around some setting, I wanted to have just a command to run and, here we go, everything ready.

One day, one of the lazy ones, I didn’t want to lose my mind trying to reproduce my favourite environment in the nth new machine. I started googling a bit looking for a better approach and I found my eldorado https://dotfiles.github.io/, an entire page of Github dedicated to exactly this annoying procedure.

Following the approach of “copy from the best” I created a small repo containing my basic set up.

The magic box

This is the structure of the ring repo:

    ├── Brewfile
    ├── Makefile
    ├── README.md
    ├── git
    │   ├── gitconfig
    │   └── gitignore
    └── zsh
        ├── aliases
        └── zshrc

Brewfile

It’s where all the programs/apps are installed from git to flux and some Finder improvements.

Makefile

It’s the engine and were the magic happens. It contains a bunch of symlinks that copy the bash and git setting into the root directory of the user:

symlinks:
    @ln -sf $(DIR)/git/gitconfig ~/.gitconfig
    @ln -sf $(DIR)/git/gitignore ~/.gitignore
    @ln -sf $(DIR)/zsh/zshrc ~/.zshrc

There is a part also dedicated to the installation and the upgrade of the programs via brew:

brew:
    brew update
    brew upgrade
    brew tap Homebrew/bundle
    brew tap caskroom/versions
    brew bundle
    brew cleanup

git/

ça va sans dire, it contains all the settings related to git.

zsh

See above, all the settings related to the CLI.

Up and running

There are just a couple of pre-requisites, that I the future I want to automate as well:

Once that these two are installed you are ready to rock.

First of all download the git repository:

git clone https://github.com/sirLisko/dotfiles.git
cd dotfiles

And the install them:

    make

That’s it.

To infinity and beyond

Unfortunately, I didn’t have much time to work on improving and expanding them. There are definitely a bunch of things I’d like to optimise, for example, removing the pre-requisites. A draft of future implementation includes:

For the moment I am already pretty satisfied enough with the work I’ve done around them.

I suggest playing with your dotfiles, it’s a good exercise and well spent time, you will definitely learn a lot of new things and the next time you have to set up a new machine you will feel like a magician.