From time to time, I like to analyze which unix or linux shell commands I’m using most frequently. To do this, all I need is a little awk, like the following:
So what does this do?
Basically, it parses your history looking at the 2nd column, which is the command you typed and increments it each time it is found. Then it displays a sorted report showing the count of the command and the command, like this example on my MacBook Pro:
Based on this output of the top 10 most frequently used shell commands, it shows that I’m using git, and ls quite a bit so it would be helpful to create aliases for these commands. Here are a few examples:
Now that I know git is one of my most used commands I can parse my history to determine what git command I use most frequently:
The output of that command provides me with this information:
This now allows me to tailor my aliases for git accordingly.
By tailoring your aliases appropriately you can speed up your workflow significantly, as well as reduce the wear and tear on your fingers.