自分のコマンド履歴をグラフ風にしてながめてみたい
準備
historyログに日時を追加と件数を増やす
$ echo "### history" >> ~/.bash_profile
$ echo "HISTTIMEFORMAT='%y/%m/%d %H:%M:%S '" >> ~/.bash_profile
$ echo "HISTSIZE=100000" >> ~/.bash_profile
準備完了!
人気コマンドランキング(俺)
history | awk '{h[$4]++}END{for(i in h){print h[i],i|"sort -rn|head -20"}}' |awk '!max{max=$1;}{r="";i=s=60*$1/max;while(i-->0)r=r"#";printf "%15s %5d %s %s",$2,$1,r,"\n";}'
結果例
git 105 ############################################################
npm 77 ############################################
vi 72 ##########################################
ls 66 ######################################
cd 64 #####################################
history 30 ##################
pwd 13 ########
nvm 9 ######
rm 8 #####
node-debug 8 #####
exit 8 #####
cp 8 #####
sudo 6 ####
sh 6 ####
find 6 ####
echo 6 ####
brew 6 ####
perl 5 ###
mvn 5 ###
express 5 ###
日別コマンド数グラフ(俺)
history | awk '{h[$2]++}END{for(i in h){print h[i],i|"sort -k 1|head -20"}}' |awk '!max{max=$1;}{r="";i=s=60*$1/max;while(i-->0)r=r"#";printf "%15s %5d %s %s",$2,$1,r,"\n";}'
結果はサンプル少ないので省略
まとめ
- 楽しいw
- 次は日別コマンドランキングを集計してgoogleトレンド風に推移をみれるようにしてみる