xclip

Updated: 07 May 2023

Pipe command to primary (middle mouse button) clipboard

cmd | xclip

Pipe command to ‘clipboard’ clipboard, for pasting into another application

cmd | xclip -sel clip

Copy contents of file to clipboard, for pasting into another application

xclip -sel clip file.txt

Ubuntu select and paste with Mouse Keys

Updated: 04 February 2021

On Linux I like to make use of the select and paste feature i.e. selecting text copies it and the middle mouse button pastes it. When a laptop touchpad has no buttons a middle mouse click can be simulated with a three-finger tap, but this is awkward.

Here is my workaround (for keyboards with a numeric keypad only):

  1. From the Accessibility menu turn on Mouse Keys.
  2. Ensure the Number Lock is off.
  3. Select text.
  4. Paste text by pressing 5 on the numeric keypad.

Furthermore, in a terminal and some other applications SHIFT + INSERT will paste text which has been previously selected.

I am using Ubuntu 20.04.1 and GNOME 3.36.8