Skip to content
loading...

re: What are your top ten command lines? VIEW POST

FULL DISCUSSION
 

I'm using zsh and this command didn't work well. I found this post which includes something nice! Here's mine:

~% history 1 | cat | 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 -n10
     1  300  25.5537%    ag
     2  95   8.09199%    g
     3  61   5.19591%    gl
     4  49   4.17376%    gb
     5  45   3.83305%    ls
     6  43   3.66269%    cm
     7  42   3.57751%    cd
     8  39   3.32198%    cat
     9  28   2.38501%    brew
    10  26   2.21465%    rm

ag is the command for the_silver_searcher -- I guess I search a lot!

 

If you use zsh you can use the command zsh_stats.

 

Nice! I didn't know about zsh_stats. It would have saved me some time tinkering with cut and uniq :P

$ zsh_stats                                                                      
     1  828  7.84165%     git
     2  691  6.54418%     gst
     3  533  5.04783%     gco
     4  469  4.44171%     cd
     5  439  4.15759%     ggpush
     6  367  3.47571%     gca
     7  363  3.43783%     grunt
     8  357  3.381%       ls
     9  299  2.83171%     npm
    10  291  2.75594%     make
    11  288  2.72753%     code
    12  248  2.34871%     open
    13  188  1.78047%     node
    14  188  1.78047%     hexo
    15  171  1.61947%     z
    16  156  1.47741%     brew
    17  145  1.37324%     ggpull
    18  141  1.33535%     ..
    19  138  1.30694%     cat
    20  136  1.288%       eos
 

Oh, that's weird it didn't work for you. I'm also using zsh. I'm just curious, what was not working with the original command?

 

It just shows a bunch of commands with a count of 1 :-) The zsh_stats thing is very cool!

code of conduct - report abuse