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.

1
  • 1
    Of course the root cause of the problem is that GNU Readline does not have a proper ECMA-48 parser (c.f. 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

Bind them to redraw-current-line.

4
  • 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. – mosvy Dec 11 '19 at 17:54
  • There is nop. But unbinding is the correct thing to do, see @paradroid's answer. – kkm Apr 12 '20 at 7:30
  • Where is nop? – mosvy Apr 12 '20 at 8:35
  • 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 Apr 14 '20 at 6:44
2

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

# Ctrl-Up
"\033[1;5A": ""
# Ctrl-Down
"\033[1;5B": ""
1
  • 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 Apr 12 '20 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.