Skip to content

Instantly share code, notes, and snippets.

@mh61503891
Created April 30, 2014 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mh61503891/10c86974cc8b3ddeeac9 to your computer and use it in GitHub Desktop.
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.
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($/)
@mh61503891
Copy link
Author

$ 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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment