Sha256: 31a4886db284f99ed35d04deeff99c9cbf8052edef4879df005547b1d7b1f736

Contents?: true

Size: 881 Bytes

Versions: 1

Compression:

Stored size: 881 Bytes

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)
fragments = @history.fragment.values.select{|a| a.count >= 5}
max_fragment_size = fragments.map{|a| a.body.size }.max
puts "types\tcount\tcommand#{" " * (max_fragment_size - "command".size)} => shorten command"
fragments.sort{|a, b| a.types <=> b.types }.reverse.each do |value|
  if @alias_list.shortenable?(value.body)
    puts "#{value.types}\t#{value.count}\t#{value.body + " " * (max_fragment_size - value.body.size)} => #{@alias_list.shorten_command(value.body).map{|h| "\"#{h}\""}.join(",")}"
  else
    puts "#{value.types}\t#{value.count}\t#{value.body + " " * (max_fragment_size - value.body.size)} => no alias"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alias_metrics-0.1.2 bin/alias_candidates