Sha256: 7f6833dfa1cf1f63eb5dd1a9e16f627725368633230b731cdc68bab0afe8eeba
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
#!/usr/bin/env ruby lib = File.dirname(__FILE__) + '/../lib/' $:.unshift lib unless $:.include?(lib) require "alias_metrics" include AliasMetrics @alias_list = AliasList.load_from_stdin @history = CommandHistory.load_from_zsh_history(@alias_list) command_length_all = @history.commands.map{|command| command.size}.inject(0){|partial_sum, size| partial_sum + size} shorten_count = @history.shorten_count shorten_rate = shorten_count.to_f / command_length_all shortenable_count_all = @history.shortenables.values.inject(0){|partial_sum, shortenable| partial_sum + shortenable.count * [0, (shortenable.command.size - shortenable.alias.size)].max } shortenable_rate = shortenable_count_all.to_f / command_length_all puts "You reduce #{sprintf("%0.2f", shorten_rate * 100)}% types (#{shorten_count} types/ #{command_length_all} types)" puts "If you use alias all, you can reduce more #{sprintf("%0.2f", shortenable_rate * 100)}% types (#{shortenable_count_all} types / #{command_length_all} types)" puts puts "You often forget the following alias" puts "alias\t#used\t#forgot\tforgot rate(%)\tcommand" keys = @history.shortenables.keys.sort{|a, b| @history.shortenables[a].count <=> @history.shortenables[b].count }.reverse keys.each do |key| shortenable = @history.shortenables[key] alias_usage = @history.alias_usages[shortenable.alias] forgot_rate = shortenable.count.to_f / (alias_usage.count + shortenable.count) puts "#{shortenable.alias}\t#{alias_usage.count}\t#{shortenable.count}\t#{sprintf("%0.2f", forgot_rate*100)}\t#{shortenable.command}" end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
alias_metrics-0.1.2 | bin/alias_metrics |