0

What is the best way to obtain a two-way dictionary between a specific key (specified by either a descriptive name or by the press of a the corresponding key) to a code like \e[7~ as used in .inputrc and vice versa.

I have read https://superuser.com/a/269471/728074 but it doesn't help much. Not only would it be cumbersome to have to look in the output of either infocmp -L -1 or infocmp -L -1 xterm for any key specified in .inputrc but it doesn't even seem to contain the ones I find in my .inputrc file. For example the key "\e[7~" found in .inputrc is not found anywhere in the output of those commands. Nor are the other examples given in both that question and answer.

I have also read https://unix.stackexchange.com/questions/76566/where-do-i-find-a-list-of-terminal-key-codes-to-remap-shortcuts-in-bash, but running sed -n l and then for example the home key reveals a different key than the .inputrc file suggests I should find.


sed -n l

followed by the home key and enter gives:

^[[H
\033[H$
Kvothe
  • 145
  • 11

1 Answers1

1

The answer you linked to is very comprehensive and correct.

Basically ^[[H and \033[H are exactly the same sequence, just different representation of the same character: 033 octal is the binary code for Ctrl+[.

The first line is the local terminal echo from the terminal device, while the second line is output by sed (excluding the $).

This shouldn't be specified differently anywhere else.

harrymc
  • 498,455