Dotfiles: Automating my laptop setup
I don't know about you but I usually spend a full day when setting up a new computer, and still forget to configure something here or there. Of course there are several solutions that claim to solve this problem and I'm here to present the one I've chosen.
Automation + Documentation: Automate everything that you can and document the steps you couldn't automate.
For some time I've been keeping a runbook with the steps I take when getting a new computer (or reseting my current one) and eventually automate some steps in a project called dotfiles.
Context
Dotfiles is a concept where you create a project that backs up and automatically installs your system preferences, and other things you might want. People also usually create handy scripts and have them in a bin
folder, kind of creating your very own toolbox
.
The name dotfiles
comes from those files that start with a dot, very common in Unix/Linux systems (like .bashrc
or .gitignore
). So usually dotfiles projects start by backing up such files, and then it grows as the owner's taste.
In Unix-based systems, programs are usually configured either via shell
arguments or text-based configuration files. Some of these programs allow per-user configurations, and those are usually placed in your home directory. These files start with a dot to make them hidden in a default view or file listing. Such files dictate how you use your system, so it's a very good approach to have them backed up and up-to-date.
My Dotfiles
You can find my dotfiles on my github. I have setups for MacOS and Linux, although the linux part may be broken (I'm using mostly MacOS these days). For mac here's what it does:
- Install powerline fonts, they're used on my iTerm setup
- Copy configuration files (THE dotfiles, like
zshrc
orBrewfile
) to my home directory - Install Homebrew
- Install iTerm theme (I use Cobalt2) and some zsh plugins
- Create
~/.ssh
folder if it doesn't exist. Create auth keys if doesn't exist, copy my default ssh config file - Run sub-configuration setup if there's any. I use this for company-specific stuff, or if I'm doing something privately
- Setup some sudo configs (e.g. use fingerprint when executing sudo instead of typing password)
- Setup dozens of preferences on Mac
These take care of most of my laptop configurations. For the rest I look at my runbook, which I recently published in a blog post on how I setup a new laptop.
Idempotent
This is a fancy word that means you can execute a method/function/script/program without changing the result you got on the initial application. Ideally you'd want your dotfiles installation to do that, because then you can install them several times and get a fresh start without any hard consequences.
Sharing
For me sharing your dotfiles is a very important part of it. You can get inspiration from other dotfiles, and inspire others with your own project. Not to mention the accountability that public stuff usually have by making you put more effort on tidying up those files.
All in all, this is more about the journey than the destination.
To get more in depth with this idea please visit this unofficial guide to dotfiles on GitHub or this awesome-dotfiles list on github.