Skip to content

Instantly share code, notes, and snippets.

@nicksarafa
Last active June 20, 2017 01:29
Show Gist options
  • Save nicksarafa/a505feb9140a342d22dbf3c27cc92dd5 to your computer and use it in GitHub Desktop.
Save nicksarafa/a505feb9140a342d22dbf3c27cc92dd5 to your computer and use it in GitHub Desktop.
Sweet little one liner that returns the top 25 most frequent commands ran inside your shell

bash-stats

history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n25


Example results

 1	2165  21.6522%   git
 2	1000  10.001%    gco
 3	739   7.39074%   docker
 4	514   5.14051%   npm
 5	497   4.9705%    cd
 6	469   4.69047%   vim
 7	449   4.49045%   h
 8	413   4.13041%   mv
 9	389   3.89039%   gcloud
10	279   2.79028%   gd
11	278   2.78028%   rm
12	253   2.53025%   touch
13	176   1.76018%   yarn
14	153   1.53015%   mkdir
15	146   1.46015%   heroku
16	130   1.30013%   brew
17	74    0.740074%  mvim
18	62    0.620062%  open
19	60    0.60006%   alias
20	59    0.590059%  gulp
21	50    0.50005%   node
22	44    0.440044%  glol
23	38    0.380038%  redis-cli
24	36    0.360036%  y
25	35    0.350035%  python
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment