4

How do i write data from the Command-line into the copy paste buffer? I see the programs xsel, and xclip and they look fine, but i would prefer a command line option. Can i redirect terminal output to the buffer some how? What is the technical name for the copy paste buffer?

I use mate for the desktop environment. The reason I want to be able to do this without installing anything is I want to be able to write scripts to use this function even on systems where i am not an administrator... i know i can compile in my home directory, but i would still prefer a standard output method. I wouldnt mind writing a bit of c-code to do it either.

I am still not certain, perhaps the copy paste buffers are just frame buffers?

Braiam
  • 67,791
  • 32
  • 179
  • 269
j0h
  • 14,825
  • I guess it depends on the virtual terminal application you're running. Do you run gnome-terminal, xterm or something else? Do you use X or is it just the linux console? –  Nov 05 '13 at 03:20
  • I think I was asking where the copy paste buffer is, not how to do it manually, but programaticly. I'm sure I used expect, and xev to solve it, – j0h Sep 05 '20 at 14:42

2 Answers2

5

To redirect STDOUT to the X11 clipboard, you can pipe it into xclip:

$  echo -n my example text to STDOUT | xclip -i -selection clipboard

You can see what's in the clipboard with:

$  xclip -o -selection clipboard

See xclip man page for more details.

0

The simplest way (if I understand correctly what you want) is to select the text with your mouse and then use CTRLSHIFTC to copy it into the regular clipboard. From there you use the standard CTRLV to paste it into any application in your GUI.

To paste copied text from the GUI into the terminal you use CTRLSHIFTV.

guntbert
  • 13,134