Class: AliasManager::LogLine

Inherits:
Object
  • Object
show all
Defined in:
lib/alias_manager/log_line.rb

Class Method Summary collapse

Class Method Details

.allObject



3
4
5
6
7
8
9
# File 'lib/alias_manager/log_line.rb', line 3

def self.all
  logs = File.readlines("#{ENV['HOME']}/.zsh_history")

  logs.map do |log_line|
    log_line.force_encoding("iso-8859-1").split(";").last.chomp.split(" ").first
  end
end

.countsObject



11
12
13
14
15
# File 'lib/alias_manager/log_line.rb', line 11

def self.counts
  all.group_by { |command| command }.map do |command, commands|
    [command, commands.count]
  end.to_h
end