Created
April 30, 2014 15:46
-
-
Save mh61503891/10c86974cc8b3ddeeac9 to your computer and use it in GitHub Desktop.
Printing of a list of a ranking of the number of runs of commands of a history of a bash.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts open(File.join(File.expand_path('~'), '/.bash_history'), &:readlines).map{ |c| File.basename(c.strip.split.first.to_s) }.compact.inject(Hash.new(0)){ |h, a| h.tap{ h[a] += 1} }.sort_by{ |pair| -pair.last }.map{ |pair| "#{pair.first}(#{pair.last})" }.join($/) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ ruby script.rb | head ls(2040) rake(1385) cd(842) ruby1.9(496) bundle(332) DEBUG=true(279) open(231) less(179) pwd(156) ruby(147)