Created
March 5, 2012 13:26
-
-
Save hotchpotch/1978295 to your computer and use it in GitHub Desktop.
pry clipboard copy utility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def pbcopy(str) | |
IO.popen('pbcopy', 'r+') {|io| io.puts str } | |
output.puts "-- Copy to clipboard --\n#{str}" | |
end | |
Pry.config.commands.command "hiscopy", "History copy to clipboard" do |n| | |
pbcopy _pry_.input_array[n ? n.to_i : -1] | |
end | |
Pry.config.commands.command "copy", "Copy to clipboard" do |str| | |
unless str | |
str = "#{_pry_.input_array[-1]}#=> #{_pry_.last_result}\n" | |
end | |
pbcopy str | |
end | |
Pry.config.commands.command "lastcopy", "Last result copy to clipboard" do | |
pbcopy _pry_.last_result.chomp | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment