Clipboards

X11 has these things called ""selections.” They have names. There are really only two you need to know about: the Primary selection and the Clipboard selection. An application is said to "own” a selection when it raises its hand and says, "I have the Primary selection now.” Only one application can own a selection at a time, so when one app asserts selection ownership, the previous owner loses it.

Asserting ownership of a selection doesn’t actually transfer data. When you want to copy text from application A to application B, it goes like this:

  • Copy text in program A: program A asserts selection ownership.
  • Paste text in program B: program B notes that program A owns the selection.
  • program B asks A for the text.
  • program A responds, and sends the text to program B.
  • program B pastes the response.

Clipboard: for when the user has explicitly copied something (e.g., the Edit/Copy” menu item.)

Primary: more ephemeral and implicit: it is for when the user has highlighted or selected something (e.g., dragging the mouse over some text.)

ref: http://www.jwz.org/doc/x-cut-and-paste.html

Shortcuts:

Copy/Phase of the Clipboard are usually implemented as Ctrl+C/Ctrl+V

Phase from Primary clipboard are implemented as the middle button. (there are very few programs did implement the support of primary selection.)

Shift+Insert seems to sometimes use the Primary Selection, sometimes the Clipboard. And some program don’t support shift+inert(like firefox, but it support middle button). Middle button is the Standard one

And since Windows only have one clipboard, whick behaves the same as the X11 Clipboard, the above shortcuts, if implemented/supported, will use the same clipboard.

Command line tools

Linux: xclip

xclip board is a command line interface for the X11 clipboard. You can use it to copy the content to a specific clipboard

    ls -al | xclip
    ls -al | xclip -selection clipboard

Windows(cygwin): putclip/getclip

    ls -l | putclip.exe
    getclip.exe > foo.txt

Comments !