0

I know that if I want to make xterm erase a character when I press backspace, I do: stty erase ^? but I also want xterm to erase a character when I press shift+backspace, and I can't find an explanation for how to do this.

With a little C program using ncurses, I have determined that when I press shift+backspace, it translates to the following sequence of bytes:

27 91 51 59 50 126

When I press ctrl-v and then shift+backspace, it shows up in xterm as:

^[[3;2~ (where ^[ is, of course, the escape character, ASCII byte 27).

I have tried doing stty erase followed by ctrl-v, shift+backspace but I get the following result:

 ~ > stty erase ^[[3;2~ stty: invalid integer argument `\033[3' Try `stty --help' for more information. 2~: Command not found. 

Is there a way to do this? Or is it impossible because shift+backspace is not a single byte but 6?

5
  • 2
    try xterm -xrm '*VT100*translations: #override Shift <Key>BackSpace:string(\1 77)', and if it works, make that xrm argument loaded by xrdb in each session (usually by adding it to ~/.Xresources, though that's not guaranteed to work on all desktops) Commented Oct 24, 2019 at 16:00
  • 1
    stty can only "bind" single bytes, not escapes like ^[[3;2~, and cannot bind multiple bytes to the same action. Commented Oct 24, 2019 at 16:01
  • I tried that xterm -xrm ... command, but it doesn't perform a backspace when I do shift+backspace. However, it also doesn't echo 2~, which was the current behavior; it just nothing. Any idea what might be going on? Commented Oct 24, 2019 at 18:17
  • 1
    copy-pasto, my bad, sorry; a space has slipped between the \1 and the 77 of \177 (same as 0x7f ^?). Corrected command: xterm -xrm '*VT100*translations: #override Shift <Key>BackSpace:string(\177)' Commented Oct 24, 2019 at 18:51
  • Perfect! Thanks so much! Commented Oct 24, 2019 at 18:57

1 Answer 1

0

As pizdelect pointed out in a comment:

xterm -xrm '*VT100*translations: #override Shift <Key>BackSpace:string(\177)'

Put this into ~/.Xresources to have it loaded by xrdb for each session.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.