Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 37 lines (29 sloc) 0.843 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
# vim:set ft=ruby:

def pbcopy(str)
  IO.popen('pbcopy', 'r+') {|io| io.puts str }
end

Pry.config.commands.command 'hcopy', 'Copy a history to clipboard' do |n|
  pbcopy _pry_.input_array[n ? n.to_i : -1]
end

Pry.config.commands.command 'copy', 'Copy a text to clipboard' do |str|
  pbcopy str
end

Pry.config.commands.command 'lastcopy', 'Copy the last result to clipboard' do
  pbcopy _pry_.last_result.chomp
end

if defined?(Hirb)
  Hirb::View.instance_eval do
    def enable_output_method
      @output_method = true
      @original_print = Pry.config.print
      Pry.config.print = -> (output, value) {
        Hirb::View.view_or_page_output(value) || @original_print.call(output, value)
      }
    end

    def disable_output_method
      Pry.config.print = @original_print
      @output_method = nil
    end
  end

  Hirb.enable
end
Something went wrong with that request. Please try again.