Chap
Chap

Reputation: 3835

Scripted access to Linux clipboard from terminal

I'm using a terminal emulator (MATE, to be exact) running on Linux Mint, which is running in a VM hosted by Windows. I'm connected to a bash shell on CentOS Linux via ssh. I'm not using X-anything. I am able to copy and paste, using the mouse, between my MATE emulator and Windows.

What I want is to write scripts that can read from, and write to, the buffer that Mint uses for cutting and pasting. Once upon a time, on some other *nix (Cygwin, perhaps?) it appears like I could read and write /dev/clipboard, but there's no such thing in Mint. Mac OSX has pbcopy and pbpaste, and there are apparently plenty of solutions when using X-Windows, but none of these seem to address my 'terminal' environment, from all my googling.

I'd like to be able to scrape text from my MATE terminal (or a Windows window, which auto-synchronizes its clipboard with that of Mint) using my mouse, and then run a Perl script that filters that text somehow. Or conversely, have a script on Mint populate the clipboard allowing me to paste elsewhere. Can this be done?

Upvotes: 2

Views: 701

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798526

The mouse selection is the PRIMARY selection. The copy selection is the CLIPBOARD selection. Both can be accessed with xclip.

Upvotes: 2

Related Questions