You are not logged in.

#1 2014-09-02 20:53:12

lawrent
Member
Registered: 2014-08-26
Posts: 31

Change keyboard shortcut for copy/paste in xterm

Hi,

I'd like to change the key bindings in xterm for copy-paste to ctrl-c and ctrl-v rather than middle click and shift-insert.

Is there a way to do so?

Offline

#2 2014-09-02 21:35:32

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,545
Website

Re: Change keyboard shortcut for copy/paste in xterm


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2014-09-02 22:38:52

lawrent
Member
Registered: 2014-08-26
Posts: 31

Re: Change keyboard shortcut for copy/paste in xterm

By your second link, I imagine you mean that the copy-paste shortcuts can be redefined by a clipboard manager?

Hints found here:
- xbindkeys + parcellite/any other clipboard manager > still need to read
- xdotool > associate ctrl-c to the command "xdotool click 2". However I don't like this way of doing because depending on the application, ctrl-c may then behave differently.

Offline

#4 2014-09-03 00:24:30

lawrent
Member
Registered: 2014-08-26
Posts: 31

Re: Change keyboard shortcut for copy/paste in xterm

Okay, here I am.

.xbindkeysrc:

"xdotool click 2"
control+shift+c

"xdotool Shift+Insert"
control+shift+v

(with clipit, but that doesn't matter.)

Ctrl-shift-c works fine, ctrl-shift-v doesn't. xdotool Shift+Insert works fine too when it's directly typed in xterm.

Any hint?

Offline

#5 2014-09-03 03:32:02

Theta91
Member
Registered: 2014-08-21
Posts: 13

Re: Change keyboard shortcut for copy/paste in xterm

xdotool Shift+Insert doesn't work for me. I think you want: "xdotool key Shift+Insert"

Last edited by Theta91 (2014-09-03 03:32:24)

Offline

#6 2014-09-05 01:24:39

lawrent
Member
Registered: 2014-08-26
Posts: 31

Re: Change keyboard shortcut for copy/paste in xterm

Yeah I meant "xdotool key Shift+Instert".

I've found another way to paste but the bug is still the same:
when I "xdotool click 1" directly in xterm it yanks the selection in the clipboard and "xdotool click 2" pastes it.
Now if I write my .xbindkeysrc like

"xdotool click 1"
control+shift+c

"xdotool click 2"
control+shift+v

then:
ctrl-shift-c copies the selection to the clipboard and deselects it after;
ctrl-shift-v copies the selection to the clipboard without deselecting it;
typing manually "xdotool click 2" to the console still pastes what was copied by ctrl-shift-c and ctrl-shift-v.

Is there a way to directly remap the copy and paste functions inside an xterm config file, rather than passing through xbindkeys?

Edit: alternative way of doing. Adding a "paste from clipboard" functionality to zsh's vi mode. Will take a closer look tomorrow.

Last edited by lawrent (2014-09-05 02:03:55)

Offline

#7 2014-09-05 03:13:40

Theta91
Member
Registered: 2014-08-21
Posts: 13

Re: Change keyboard shortcut for copy/paste in xterm

I use iocane now, but I reinstalled xbindkeys and xdotool to take a look, and it's completely non-functional for me in xterm.

In urxvt, however, everything works as expected (C-S-v pastes without deselecting). It seems likely that your problems are caused by xterm rather than xdotool+xbindkeys - perhaps try a better terminal?

Offline

#8 2014-09-05 12:51:56

lawrent
Member
Registered: 2014-08-26
Posts: 31

Re: Change keyboard shortcut for copy/paste in xterm

Yeah, I wouldn't be surprised if the problem comes from xterm. Quoting the st terminal project,

What is wrong with xterm?

xterm is bloated and unmaintainable. Here’s an excerpt from the README:

                Abandon All Hope, Ye Who Enter Here


This is undoubtedly the most ugly program in the distribution.  It was one of
the first "serious" programs ported, and still has a lot of historical baggage.
Ideally, there would be a general tty widget and then vt102 and tek4014
subwidgets so that they could be used in other programs.  We are trying to
clean things up as we go, but there is still a lot of work to do.

Needless to say things have not changed, it’s still ugly. It has over 65K lines of code and emulates obscure and obsolete terminals you will never need. The popular alternative, rxvt has only 32K lines of code. This is just too much for something as simple as a terminal emulator; it’s yet another example of code complexity.

I'll have a closer look later on today, discovering the whole Linux universe is quite brain-intensive.

Offline

Board footer

Powered by FluxBB