As a software developer I use the terminal a lot. As I look for ways to save time and become more efficient it would make sense to reflect upon my terminal usage. I couldn’t say with certainty which commands I use the most. I’ve hammered them into the spinal cord.

Luckily there is the bash history. Making a “historytop” command is relatively simple. This command prints your top ten most used commands.

Breakdown of the Command

Let’s break down how the command works.

You can type “history” in your terminal to see your bash history. This history is usually capped at a length of 500 and each command is prefixed with line numbers:

We are not interested in the line number. The “cut -c 8-” remedies that by removing the first 7 letters from each line:

Next is “sort | uniq -c” which groups them up with a count:

The “sort -nr” stands for sort numeric reverse, which places the high ones at the top:

Finally we use “head -10” to pick the first ten lines only.

Reflection and Improvements

#1: At the top of the list we have “git status” and “git diff”. Now that I see the statistics I realise I have a habit of typing these commands before every commit to see I’m not committing the wrong stuff. I also need to see the output to figure out a good commit message.

Let’s make a single letter bash alias “i” as in “information”:

#2: I use “git push” quite often.

Let’s make a single letter bash alias “p” as in “git push”:

#3: It would seem it’s common for me to check out the develop branch.

Let’s make a couple of single letter bash aliases “d” as in “develop” and “m” as in “master”.

#4: Finally committing is a common action.

Let’s make a single letter alias “c” as in “commit”:

A Personal “Journey”

I feel the aliases above will be really useful to me. However they may not be optimal for you. Chances are your workday looks different than mine. As such making bash aliases is likely a personal journey.

Perhaps in that sense quite similar to “dotfiles”?¬†You could copy an exiting dotfiles repo, but it might not suit you. The reflection and iterative improvement process itself is of importance.