Home » Questions » Computers [ Ask a new question ]

How to bind a function to Control-2 key combo on bash

How to bind a function to Control-2 key combo on bash

I want to set a key binding in bash for "history-search-backward" readline command to a combination of Control+some other key (I'm using 2 as an example), but I'm unable to do so.

Asked by: Guest | Views: 280
Total answers/comments: 1
bert [Entry]

"There's no ASCII code for Control-2. Control-@ through Control-_ correspond to control codes 0x00 (NUL) through 0x1F (Unit Separator). For example, the code for Control-I is the code for 'I' (0x49) minus 0x40 = 0x09 (HT, aka tab). There's no set definition for Control+(some other character not in the @ to _ block).

Programs that do their own keyboard handling can interpret Control any way they like in combination with any other keys. But programs like bash, which read their input through a terminal, don't have any way of even seeing Control-2."