When I copy something to the clipboard and press Ctrl + V in Bash, nothing happens; However, right clicking and selecting Paste does the job.
Why? Is there any reasonable issue (I'm sure there is) behind this behavior in Linux?
|show 2 more comments|
In the days of physical terminals, session-wide clipboards did not exist, only few programs supported internal copy/paste – often under the name of "buffers" or "kill rings" – and used various different keystrokes. For example, the bash shell uses CtrlK or CtrlU to "kill" (cut), CtrlY to "yank" (paste); this comes from the emacs editor.
CtrlC almost everywhere in Unix was the "interrupt" key, used to cancel the current program or operation. The CtrlV key often meant "verbatim insert" – that is, insert the following character literally without performing any associated action. For example, a normal Esc switches to command mode in the vi editor, but CtrlV, Esc will insert the
The use of CtrlC to copy and CtrlV to paste from session-wide clipboard was introduced by Xerox PARC[unsure] around 1974, later by Mac OS in 1983 and Microsoft Windows 3.x in 1990. (Earlier Windows versions (1.x and 2.x), as well as IBM OS/2, only supported the IBM CUA keys CtrlIns to copy and ShiftIns to paste; these shortcuts remain supported by all Windows versions.)
When GUIs with clipboard support finally reached Unix, the Ctrl keypresses were already in use by many terminal programs. In addition, the X graphical interface had somewhat different mechanisms: "selections" and "cut buffers". Even now you can select text in one program and insert it using the middle mouse button, without any explicit copy action.
In short, by the time Xterm and GNOME Terminal were written (I'm guessing you use the latter), CtrlV already had a completely different meaning for many years and could not be changed. In addition, an alternative method of copying text – the "selection" – was already present in X11, so explicit copy/paste action was probably considered not as important as it would be in Windows. This means that different keyboard shortcuts had to be selected – in GNOME Terminal, use CtrlShiftC and CtrlShiftV.
(Most X11 toolkits also support the CUA "copy" and "paste" keys, which do not conflict with terminal programs. Unfortunately, the implementations are rather inconsistent – CtrlIns copies to the "clipboard" in most programs (GTK, Qt4, but ignored by Xaw); however, ShiftIns pastes from the "primary selection" in most GTK and Qt4 programs, but from "clipboard" in Firefox, and from the now-obsolete cut-buffers in the now-obsolete Xaw.)
(Thanks to bonyiii for reminding me about the CUA keys.)
|show 4 more comments|
Use CtrlShiftV for pasting.
Ctrl with other chars is usually used by the shell for special functions.
Here's your general-purpose copy paste settings with popular terminals:
gnome-terminal (most popular on Linux)
PuTTY (most popular terminal in Windows)
It is a deep rooted tradition that the Ctrl key together with a letter generates ASCII control characters found by subtracting 64 from the upper case letter's ASCII value. This calculation maps Ctrl-A to 1, and so on. For instance Ctrl-I is Tab and Ctrl-J is linefeed.
There is no similar tradition for Ctrl-Shift. Ctrl-Shift-V is not expected to produce any specific character.
Terminal emulators must support tradition by transparently passing through the Ctrl convention, letting it appear as character input to the programs being operated through that terminal window. Terminal-based programs map control keys to commands. For example, Bash uses Ctrl-V as a command which means "take the next character literally". This allows you to embed a control character in the command line. If the terminal steals control keys for its own use, such commands become unavailable. So intercepting Ctrl-V for a meta-function is out of the question (at least in a default configuration).
However, terminal emulators are free to intercept Ctrl-Shift-V which isn't expected to generate a character. Ctrl-Shift-V isn't a standard; it's a Gnome Terminal thing (which may be in some other terminals).
On X-based Unix desktops the convention is that no command is needed to copy. You just select the text. And the middle button pastes that text elsewhere. You will find that it works in Xterm, Gnome Terminal and Firefox alike.
Ctrl-V is a Microsoft Windows convention, which is an imitation of Apple-V from the Macintosh.