2

You can bind keys like Ctrl-Left and Ctrl-Right in .inputrc like this:

# Ctrl-Left
"\033[1;5D": backward-word
# Ctrl-Right
"\033[1;5C": forward-word

How would I bind Ctrl-Up and Ctrl-Down to nothing?

# Ctrl-Up
"\033[1;5A": null
# Ctrl-Down
"\033[1;5B": null

This obviously does not work.

I use these keys for doing stuff in tmux (nested configuration), but often ;3~ gets output into the terminal when I use either of the keys.

I'm hoping that I will be able to bind them to nothing while still having the keys work for tmux.

paradroid
  • 1,159
  • 1
  • 13
  • 28
  • 1
    Of course the root cause of the problem is that GNU Readline does not have a proper ECMA-48 parser (c.f. https://unix.stackexchange.com/a/523308/5132 and its further reading). But how to do a no-op in Readline is a valid question in its own right. – JdeBP Dec 11 '19 at 14:23

2 Answers2

2

Bind them to redraw-current-line.

  • of course, in `bash` you can use `bind -x` with an empty script (`bind -x '"\033[1;5D":'`), but I assume that the Q is about `readline` in general. –  Dec 11 '19 at 17:54
  • There is `nop`. But unbinding is the correct thing to do, see @paradroid's answer. – kkm inactive - support strike Apr 12 '20 at 07:30
  • Where is `nop`? –  Apr 12 '20 at 08:35
  • 1
    I always thought it was a thing, but it appears that binding to any undefined function name has the same effect. `"\e=":` is bound to `possible-completions` by default. Putting any of the lines `"\e=":`,`"\e=": nop`, `"\e=": foobar` results in `bind -p | fgrep '"\e='` printing nothing (And `M-=` does not do anything). It appears either RL or bash is permissive: no diagnostics, no nothing. Sorry I was misleading you. In fact, `"\e=":` w/o arguments unbinds the key just fine. – kkm inactive - support strike Apr 14 '20 at 06:44
1

I found that another option is to use double quotation marks.

# Ctrl-Up
"\033[1;5A": ""
# Ctrl-Down
"\033[1;5B": ""
paradroid
  • 1,159
  • 1
  • 13
  • 28
  • This is the correct answer. This difference is important when the bound key is also prefix to a multi-key sequence: if the head key is not bound, readline waits for the second key indefinitely; if it's bound, only for a short timeout. – kkm inactive - support strike Apr 12 '20 at 07:33