Skip to content

Instantly share code, notes, and snippets.

@hotchpotch
Created March 5, 2012 13:26
Show Gist options
  • Save hotchpotch/1978295 to your computer and use it in GitHub Desktop.
Save hotchpotch/1978295 to your computer and use it in GitHub Desktop.
pry clipboard copy utility
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