Dotfiles – Hidden configuration files, usually found in one’s home directory, that are characterized by the dot at the beginning of the filename. Example: .profile
If you’re like me and need to access many IBM i instances, copying your dotfile configurations and keeping them synced between instances can become cumbersome. Maybe you don’t need to access multiple IBM i instances, but you have complex configurations and scripts, and would like to keep them version controlled simply for organization and backup. Whatever the reason, putting dotfiles in Github or a similar git repository host and having a script to set them up can be very handy! This article will describe how to setup a dotfile repository on Github.
Dotfiles as a Repository
It doesn’t make sense to version control the entire home directory, so how should we version control specific dotfiles? The answer is to have all the dotfiles that should be version controlled in a single project folder and symlink them to the proper path. Symlinking is the act of creating a symbolic link between one file and another file on the filesystem. As you change a file, the symlinked file will be updated and synced. Example:
/home/user/.profile -> /home/user/Tools/dotfiles/system/profile.symlink /home/user/.bashrc -> /home/user/Tools/dotfiles/system/bashrc.symlink /home/user/.history -> /home/user/Tools/dotfiles/system/history.symlilnk
In the above example, all the dotfiles we want to keep track of with Git are under the directory
Symlinking all these files one by one can be as cumbersome as keeping track of these dotfiles without Git. So how do we automate the process of symlinking these files?
Script to Install Dotfiles
Keeping track of one’s dotfiles with Git is nothing new. In fact, there are dozens of examples. I picked one at random some years ago and cannot remember which script mine is based on. The bootstrap script that I copied and modified is 121 lines and can easily be modified further to fit anyone’s needs.
The way the Bootstrap script for my IBM i Dotfiles works by setting up the Git user on the system first, then it goes through the dotfiles repository and symlinks any file or folder appended with
.symlink to the home directory of the user. It will even ask if you want to overwrite, backup, or skip each file before overwriting anything. Here’s how it looks:
Getting Started Easily
The easiest way to get started would be to either use and contribute to my dotfiles, or fork my dotfiles and use them as your own. Here’s how one would clone my dotfiles and use them:
$ git clone firstname.lastname@example.org:jbh/ibmi-dotfiles.git $ cd ibmi-dotfiles $ ./script/bootstrap
It’s that simple. The bootstrap should then walk you through the install step-by-step. Now enjoy a prettier BASH!!