by MikkoFinell · 8y ago · 0 comments
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 -n10
1 167 16.7% git
2 130 13% ll
3 94 9.4% clear
4 90 9% make
5 80 8% cd
6 57 5.7% e
7 52 5.2% cat
8 45 4.5% man
9 38 3.8% valgrind
10 37 3.7% rm
Where ´e´ is an alias for ´vim´. 1 401 16.04% git
2 337 13.48% fg
3 241 9.64% cargo
4 234 9.36% cd
5 197 7.88% ls
6 195 7.8% tig
7 165 6.6% task
8 81 3.24% vim
9 38 1.52% imag
10 31 1.24% pwd
"imag" is my own tool, a personal information management suite for the commandline. 1 93 18.6% l
2 75 15% exit
3 60 12% zsh
4 53 10.6% cd
5 47 9.4% nvim
6 20 4% ssh
7 14 2.8% lt
8 14 2.8% ls
9 14 2.8% la
10 10 2% sudo 1 178 35.5289% gi
2 90 17.9641% ls
3 77 15.3693% vim
4 51 10.1796% fg
5 28 5.58882% cd
6 20 3.99202% jobs
7 10 1.99601% date
8 6 1.1976% pass
9 5 0.998004% docker
10 4 0.798403% sudo
I know `gi` looks silly as a `git` alias but it has an ergonomic benefit at least for touch typists.but when I try to save it as an alias method.. I keep getting error:
awk: cmd. line:1: {CMD[]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;} awk: cmd. line:1: ^ syntax error awk: cmd. line:1: error: invalid subscript expression
I thought I would just escape the double quotes ", and things would work. :/ Any ideas?
alias mostused='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 -n10'Use a shell function instead of an alias, that's the better tool here.
clear && make all && ./a.out