How I increased my productivity using dotfiles

TLDR; You can set up a new system using dotfiles and an installation script in minutes. It’s not hard to create your own repository, and you’ll learn a ton along the road. This is truly more about the journey than the destination!

There is no frustrating feeling like the feeling of starting all over again especially when it comes to a fresh OS install or having your hard-drive crashing on you which then results in reinstalling your OS all over again!

And you think to yourself, OMG! my aliases, system settings and configuration files, every little helper file and script GONE, just like that!

That new fresh OS install on your new computer is a shell of its former self, everything fresh out of the box - How annoyed you will/would be.

Your heart warms as you think back to the comfort and productivity that came with your computer before. If only there was a way to take everything you know and love on the go and never to worry about the agony of reinstalling everything…

Thankfully, there is!

Overtime I got annoyed and frustrated to the point where I created my own linux setting up script that auto-installs everything I needed from packages, dotfiles, configuration files and settings.

Automate Everything!

This repository contains, and track changes for most of my important files in my /home partition, such as .bashrc, .bash_aliases, and other related files.

Dotfiles are used to customize your system. The "dotfiles" name is derived from the configuration files in Unix-like systems that start with a dot (e.g. .bash_profile and .gitconfig). For normal users, this indicates these are not regular documents, and by default are hidden in directory listings. For power users, however, they are a core tool belt.
Backing my dotfiles to GitHub keeps everything neatly tracked and version controlled.

The second repository packs a punch, it contains a script which when ran it will install every little package, configs, githooks and dotfiles, I need for my day-to-day productivity from academic, work-related to entertainment.
installer.sh is what makes this all magically work.

I have compiled a demo for the installation (I’ll document it in detail on the next post).

My Dotfiles

An Example Dotfiles Repository

For this post, I’m just going to list a subset of my own dotfiles repo.

Current Structure

Below is the structure of my dotfiles repository. It’s also what we’ll use in our walk-through below.

Diving deep into the dotfiles

We will take a look at the following examples:

.dotfiles/.profile

.dotfiles/.bashrc

.dotfiles/.bash_aliases

.dotfiles/.bash_functions

.dotfiles/.docker_aliases

.profile

This file is located in your /home directory is loaded first upon login, it is either called .profile or .bash_profile.
What to put in the .profile is truly up-to the individual and it can be expanded significantly. I personally like to keep my .profile as small possible and only have things I need to be ran once.
For example, I define all my colours and colour functions in my .profile

.bashrc is a shell script that Bash runs whenever it is started interactively i.e. when you open a new terminal. It initializes an interactive shell session.
For example, I define my PS1, shell options, key-bindings, aliases, functions and custom message.

Other dotfiles

Installing the Dotfiles

NOTE: Be careful you should have some dotfiles defined in your /home directory. Before you continue you need to ensure that they are backed up somewhere.Remember with great power comes great responsibility.

I wrote a dotfiles installation script to automate symlinking the dotfiles in the repo to your /home directory. See this .dotfiles_setup.sh for an example.
Note that the script uses ‘ln’ instead of GNU stow for symlinking - I will update the script soon.

To install the dotfiles on a new system, we can do so easily by cloning the repo:

When done, you should just run the test to ensure that the installation was successful.

bash .dotfiles/.dotfiles_setup.sh test

Conclusion

That’s it for this blog post, I hope you picked up a thing or 2 from this post.
dotfiles are a very personal thing, Look around at other repositories and start building your dotfiles the way you like. I have always had a knack for searching for various repositories containing dotfiles on GitHub and other blogs, and I have often found something useful. It is always tricky to get everything to work according to your specs but once you have everything under-control you are good to go.

Go build set up your own dotfiles and the next time when your computer crashes/reinstall OS, it won’t be that bad!