Skip to content

Instantly share code, notes, and snippets.

@andrewberls
Created May 15, 2013 23:25
Show Gist options
  • Select an option

  • Save andrewberls/5588235 to your computer and use it in GitHub Desktop.

Select an option

Save andrewberls/5588235 to your computer and use it in GitHub Desktop.
counts = Hash.new(0)
File.read("#{Dir.home}/.bash_history").each_line do |line|
cmd = line.split.first
if cmd == "git"
cmd = line.split.take(2).join("_") # git_push
end
counts[cmd] += 1
end
counts.sort_by { |key, value| value }.reverse.each do |cmd, count|
puts "#{cmd}: #{count}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment