Created
March 9, 2018 02:39
-
-
Save emanuelhfarias/c6d140dab3f287460b7c0e8184460663 to your computer and use it in GitHub Desktop.
zsh history histogram
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
#!/bin/ruby | |
require 'pry-byebug' | |
history_array = [] | |
zsh_history_path = '~/.zhistory' | |
File.open(zsh_history_path).each do |line| | |
history_array << line[15..-2] | |
end | |
module Enumerable | |
def to_histogram | |
inject(Hash.new(0)) { |h, x| h[x] += 1; h} | |
end | |
end | |
histogram = history_array.to_histogram | |
histogram_sorted = histogram.sort_by {|_key, value| value} | |
binding.pry | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment