IBM i Dotfiles – How to Configure BASH on IBM i

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 /home/user/Tools/dotfiles.

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:

Dotfiles Install

An example of the dotfiles bootstrap running.

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 git@github.com: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!!

πŸ’πŸ¦—πŸ™πŸ’»πŸŽ±πŸš² | They/Them | Coding since age 9 πŸ‘Άβž‘οΈπŸ‘¨β€πŸ’» | #Autistic w/ #CharcotMarieTooth | #IBMi + #Linux; #OpenSource #Monk; #BridgingGaps; #IBMChampion | Passionate advocate of open source and its mindset. Business owner and public speaker. Lover of animals, cooking, horror-films, hip-hop, pool, and the Oxford comma; for lists.

1 Comments

  1. Diego Kesselman

    Josh,
    My 2 cents:

    I’m trying with some success to log all user commands on ssh session using BASH, chroot and syslog on PASE with just these:

    export HISTTIMEFORMAT=”%Y-%m-%d %T ”
    export PROMPT_COMMAND=’trap “” 1 2 15; history -a >(tee -a ~/.bash_history | while read line; do if [[ $line =~ ^#[0-9]*$ ]]; then continue; fi; logger -p user.info -t “bash[$$]” “($USER) $line”; done); trap 1 2 15;’

Leave Comment

Your email address will not be published. Required fields are marked *