Skip to content

Instantly share code, notes, and snippets.

@ibanez270dx
Created October 27, 2018 20:54
Show Gist options
  • Save ibanez270dx/fa60c6e647d0425123149dae5af92aaa to your computer and use it in GitHub Desktop.
Save ibanez270dx/fa60c6e647d0425123149dae5af92aaa to your computer and use it in GitHub Desktop.
Add pbcopy to pry
# Copy and paste sourced from: https://coderwall.com/p/qp2aha/ruby-pbcopy-and-pbpaste
def pbcopy(input)
str = input.to_s
IO.popen('pbcopy', 'w') { |f| f << str }
puts "copied to clipboard"
true
rescue
puts $!
end
def pbpaste
`pbpaste`
end
Pry::Commands.block_command 'paste_eval', "Pastes from the clipboard then evals it in the context of Pry" do
_pry_.input = StringIO.new(pbpaste)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment