info | twitter | github
J-_-L | Writings on Ruby Programming
03.10.10 24.01.11
1 comment

Gem: clipboard

gem · ruby

The clipboard gem allows you to access the clipboard on Liunx, MacOS and Windows.

The focus is on simple text. You can copy a string with Clipboard.copy("string") and paste it with Clipboard.paste. That’s it ;). Basically. Now let’s take a closer look at the specific platforms.

Linux

For Linux support, the little utility xclip is needed, you can install it on ubuntu with sudo apt-get install xclip

Furthermore, you can choose, from which clipboard you want to paste (default is PRIMARYCLIPBOARD). copy copies to all clipboards in Clipboard::CLIPBOARDS. For example: Clipboard.paste :primary

MacOS

On MacOS, everything works fine :).

Windows

I’ve fought with the Win32API and still not all problems are solved (e.g. pasting with 1.9). Copying should be no problem, but you need the clip.exe program (installed by default since Vista).Now using ffi, feedback needed if it is working as expected ;).

Creative Commons License

Comments

04.10.10

grosser

nice to have this implemented cross-platform!