Skip to content

Instantly share code, notes, and snippets.

@raven-rock
Last active June 21, 2018 14:08
Show Gist options
  • Save raven-rock/483422cab6cc453f43ae07b385fa86a3 to your computer and use it in GitHub Desktop.
Save raven-rock/483422cab6cc453f43ae07b385fa86a3 to your computer and use it in GitHub Desktop.
Ruby integration with xclip. Good for monkeypatching .pryrc. This is great for Windows clipboard integration using Putty and VcXsrv.
def pbpaste
IO.popen(["xclip", "-o"]).read
end
alias paste pbpaste
class Object
def pbcopy
Thread.new do
open("|xclip -i", "w") do |p|
p.write(self.to_s)
end
end
self
end
alias xclip pbcopy
alias copy pbcopy
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment