Brain Phrye

code cooking diy fiction personal photos politics reviews tools 


History Review

[ Listen to article ]

I was curious what I’d find if I looked into my top shell commands. I’ve been saving my shell history for almost four years, so I have a fair bit of data to work with.

To start with - how much history. I made a ~/history file with the names of the bash and zsh history files. Annoyingly I didn’t put .zsh at the end of my zsh history files so this was the easier way. Then I ran this:

1
2
3
4
5
6
7
8
9
xargs git log -p < ~/history \
  | grep '^+' \
  | grep -v '^+++' \
  | sed 's/^+ *//' \
  | sed 's/;\||\|||\|\&\&/\n/g' \
  | sed 's/ .*//' \
  | grep . \
  | wc -l
  sed 's/ .*//'|grep .|wc -l

This roughly extracted all added history lines to vcsh/git and broke down my command lines to individual commands. It came up with 350,075 which is around 250 commands per day. And what were the top commands? Replacing the wc -l above with sort | uniq -c | sort -nr | head -30 yields:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  81830 git
  49642 vi
  34231 ls
  21413 cd
   9748 vcsh
   9230 grep
   8186 ssh
   7194 cat
   5789 rm
   5020 sudo
   3835 fg
   3430 cp
   3371 terraform
   3259 go
   3107 docker
   3082 make
   2534 man
   2506 mv
   2248 mkdir
   1917 sed
   1886 echo
   1746 aws
   1724 curl
   1640 for
   1609 pass
   1540 popd
   1532 less
   1463 done
   1442 do
   1389 tail

And a pie chart of the top ten:

I can break all those down into the following activities. It’s not exact because I sometimes use vi for sysadmin stuff or sed for coding, etc.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
81830 project-manage
49642 coding
34231 file-manage
21413 file-manage
9748 project-manage
9230 search
8186 sysadmin
7194 reading
5789 file-manage
5020 sysadmin
3835 context-switch
3430 file-manage
3371 sysadmin
3259 building
3107 sysadmin
3082 building
2534 reading
2506 file-manage
2248 file-manage
1917 writing
1886 writing
1746 sysadmin
1724 testing
1640 sysadmin
1609 sysadmin
1540 context-switch
1532 reading
1463 sysadmin
1442 sysadmin
1389 sysadmin

And again in pie chart form: