class Pry::Command::Hist

def process

def process
  @history = find_history
  @history = @history.between(opts[:show]) if opts.present?(:show)
  @history = @history.grep(opts[:grep]) if opts.present?(:grep)
  @history =
    if opts.present?(:head)
      @history.take_lines(1, opts[:head] || 10)
    elsif opts.present?(:tail)
      @history.take_lines(-(opts[:tail] || 10), opts[:tail] || 10)
    else
      @history
    end
  if opts.present?(:'exclude-pry')
    @history = @history.reject do |loc|
      command_set.valid_command?(loc.line)
    end
  end
  if opts.present?(:save)
    process_save
  elsif opts.present?(:clear)
    process_clear
  elsif opts.present?(:replay)
    process_replay
  else
    process_display
  end
end