TrumanWong

xclip

Manage X pasteboard

Supplementary instructions

In the X system, there are two mechanisms for copying a piece of text from one window to another, namely Selections and cut buffers.

Commonly used copy & paste uses the cut buffers mechanism; in addition, use the mouse to select a piece of text, and then press the middle mouse button in another window to copy, using the selections mechanism. Selection can be divided into master and slave selection.

When a file is selected with the mouse, the text is automatically copied to the master selection. Then press the middle mouse button in another place to automatically paste the contents of the master selection.

Both methods are convenient when you want to copy a small amount of text. But it is quite troublesome when copying large sections of text. In addition, you may frequently perform some copy and paste tasks, constantly selecting text with the mouse, and then pasting it. It's torture for the fingers.

I couldn't stand this torture, so I discovered xclip, a convenient tool for managing the content in X selections.

For example, the following command copies the contents of the file /etc/passwd to X master selections.

xclip -i /etc/passwd

Then you can copy it elsewhere by using the middle mouse button. Or the more comfortable shift+insert. The method I use most now is to manage the contents of X master selections via keybindings. For example, alt+F1 can copy the contents of my ~/f1 to X master selections, and alt+F2 can copy the contents of ~/f2. This way you can easily copy and paste content you need to use frequently. Such as commonly used passwords and so on.