Lets you access the clipboard on Linux, MacOS, Windows and Cygwin.
Clipboard.copy
Clipboard.paste
Clipboard.clear
Add to Gemfile
:
gem 'clipboard'
gem 'ffi', :platforms => [:mswin, :mingw]
- Linux: You will need the
xclip
orxsel
program. On debian/ubuntu this is:sudo apt-get install xclip
On Linux, you can choose from which clipboard you want to paste
from by
passing it as an argument. The default is CLIPBOARD.
copy
copies to all clipboards in Clipboard::Linux::CLIPBOARDS
.
Windows uses UTF-16LE as its default encoding, so pasted strings will always come in UTF-16LE. You can manually convert them to your desired encoding (e.g. UTF-8) using the String#encode method:
Clipboard.paste.encode('UTF-8')
To use the clipboard through ssh, you need to install xauth
on your server
and connect via ssh -X
or ssh -Y
. Please note that some server settings
restrict this feature.
There is a Java implementation included (Clipboard::Java
) as an option for
JRuby. On Linux, it always operates only on the CLIPBOARD clipboard.
- Native support on X (don't depend on
xclip
/xsel
) would be great
blip is a handy commandline wrapper that lets you quickly copy file content to your clipboard: blip!
Copyright (c) 2010-2016 Jan Lelis http://janlelis.com released under the MIT license. Contributions by and thanks to Michael Grosser and all the other contributors!