Single set of keyboard shortcuts for copy/paste/cut across all X11 applications

x11

A common quibble that I have when I'm running X11 on a Linux system is that there doesn't seem to be any X11-wide keyboard shortcuts for copying and pasting. Ctrlc and Ctrlv work fine across most Gtk/Qt applications, but when copying and pasting to/from a terminal emulator, Ctrlc and Ctrlv aren't viable options.

Some terms like gnome-terminal use shortcuts like CtrlShiftc/v, but this still results in an inconsistent copy+paste experience across applications.

OSX, for example, uses the Super/Command key to provide Ctrlc/v shortcuts that function across all OSX (sans X11) applications, and don't interfere with terminal emulators.

Is there any way of getting similar functionality under X11 on Linux?

Best Answer

I ended up with a partial solution to the problem by installing xbindkeys and setting up the following .xbindkeysrc in my home dir:

"xclip -selection primary -o | xclip -selection clipboard -i"
mod4+c

"sh -c 'xclip -selection clipboard -o | xvkbd -xsendevent -file - 2>/dev/null'"
mod4+v

These shortcuts allow me to copy text into the X11 clipboard from a terminal emulator like urxvt, as well as paste from the X11 clipboard into the terminal emulator. Qt applications work for copying+pasting as well.

However, when using Gtk applications (like Firefox, gedit, etc.) if I tap the Mod4+V to paste, it doesn't seem to work. If I hold the keys down for a few seconds and then release, it pastes fine. Bizarre.

Related Question