14

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?

jasonwryan
  • 73,126
noffle
  • 1,140
  • 1
  • 10
  • 19
  • 1
    One of the issues that you are going to encounter is that Ctrl-c in a terminal is the interrupt signal - I'm not sure that changing that is worth any convenience gained by copy/paste consistency... FWIW, I use this for a relatively seamless experience. – jasonwryan Mar 05 '12 at 19:45
  • Sorry for the miscommunication -- I'm not looking to bind Ctrl-c to be copy system-wide. I don't want to break terminal emulators. It'd be nice to be able to use something like Super-c/v system-wide so that it wouldn't interfere with any/most applications. – noffle Mar 05 '12 at 21:13
  • 1
    Yes, this is an excellent question and excellent insight. I say that because the same occurred to me. :-) I'm thinking we may need to create our own distro just to show the world that consistent user interfaces can be done in Linux – Dogweather Sep 30 '12 at 06:14
  • @jasonwryan For whatever reason, I failed to notice the link to muennich/urxvt-perls that your comment included. I realize this was over seven months ago, but: thanks! I still don't have a perfect solution for system-wide shortcuts, but this has proved to be an excellent addition! – noffle Oct 21 '12 at 13:29
  • Give a try to diyism myboard python version: https://code.google.com/p/diyism-myboard/downloads/detail?name=myboard.py The issue in it: http://stackoverflow.com/questions/15270420/does-anyone-know-an-xlib-function-to-trap-a-keypress-event-without-losing-the-or/15404395#15404395 – diyism Mar 21 '13 at 06:40

2 Answers2

6

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.

noffle
  • 1,140
  • 1
  • 10
  • 19
  • So the copy works as you describe. If I try to paste more than one line at a time into a gui this gives me strings of nonsense. – Clumsy cat Dec 19 '21 at 20:38
  • Ah, never mind, I'm being silly, Ubuntu now allows you to define custom shortcuts in the settings menu. No need to use xbindkeysrc. Without the delays, both command swork as they should. – Clumsy cat Dec 19 '21 at 21:02
0

One of the easiest solutions I can think about is highlighting text and simply middle mouse clicking where you wish to paste that text. Be careful how you do this though, often the end of the copied line is a new line and can cause problems if you're in a shell.

Linztm
  • 149
  • 4
  • I'm aware of the selection clipboard, but it falls short for two reasons: 1) I'm looking for a set of keyboard shortcuts, 2) selecting any other text, even accidentally, nukes whatever (likely more important) text I had selected. – noffle Mar 05 '12 at 19:01
  • 1
    As another alternative that alleviates the issue #1. You can try the solution provided here. – Linztm Mar 05 '12 at 19:22
  • Linztm: Thanks for that. I ended up using this as part of my solution. – noffle Mar 06 '12 at 02:45