Keyboard shortcuts

Keyboard shortcuts#

You’re probably already familiar with Ctrl–c to copy and Ctrl–v to paste. But since these shortcuts have special meanings in terminals, the shortcuts are Ctrl-Shift–c and Ctrl-Shift–v. These commands interact with what is confusingly called the “clipboard” selection. It is identical to the “primary” selection except for how you interact with it.

Ctrl–c sends SIGINT to the foreground process. Ctrl–v runs the quoted-insert readline command, which inserts the next character verbatim. This can be used to insert for example a Tab character without triggering autocompletion.

The contents of the primary and clipboard selections can be different. To see how, select some text and copy it into the clipboard selection using the appropriate keyboard shortcut or context menu. At this point both selections are the same, since we selected some text (putting it into the primary selection) and then did a separate action to also put the same text into the clipboard selection. If we now select some other text the primary selection will be overwritten, but the clipboard selection stays the same. This can be used to copy two things at the same time: put something in the clipboard selection, put something else in the primary selection, then paste them separately.

 

This page is a preview of The newline Guide to Bash Scripting

No discussions yet