The “bash” shell in TinyCore Linux outputs a “~” when I hit the Delete, Home, or End key
Par theYinYeti le vendredi 21 juin 2013, 14:44 - Lien permanent
As far as I understand, different command-line interpreters (the Linux console, the bash shell, busybox…) translate these keys (Insert, Delete, Home, End) to key-codes in different ways, and then the underlying programs (aterm, urxvt…) interpret these key-codes with some variations. All of this makes for a rather fragile process. If the terminfo database is up-to-date on your system, this shouldn’t be an issue. However, TinyCore Linux doesn’t seem to even have a terminfo database.
That is why “bash”, or rather the “readline” library that “bash” is using, fails to correctly handle the said keys. But “readline” can be taught.
The “readline” library relies on the
/etc/inputrc file, or the
~/.inputrc file, for configuration. So I will create a
/home/tc/.inputrc file that will tell “readline” how to handle the above four keys.
First step is knowing what is given to “readline” as input, when said keys are pressed. This is easy to find out: in a terminal, any key is output without being interpreted, as long as you enter Control+V before (press
[Control]). So I will enter these keys in a terminal in this order: Control+V, Insert, Space, Control+V, Delete, Space, Control+V, Home, Space, Control+V, End. Here is the result:
tc@FLASH:~$ ^[[2~ ^[[3~ ^[[7~ ^[[8~
^[ combination is actually a single byte meaning Escape, and it is written
\e in “readline” syntax. The “readline” man page tells me that the commands to use for my keys are respectively
end-of-line. Thus I create my
.inputrc file with the following content:
Any subsequently opened “bash” shell should behave properly. Now make sure this
.inputrc file is saved by TinyCore between reboots.