In bash, is it possible to map backward delete not to physical <Backspace> key but to some other key?

I.e., <F18> has the following escape sequence [1;5Q, and I tried adding the following to my .inputrc:

"\e[1;5Q": backward-delete-char

...but unfortunately with no success. Thus, I wonder, is it possible at all?

  • 2
    It "should" work: if your keyboard really sends that string (which you should verify). Actually, \e[1;5Q doesn't look like a possible <F18> (what terminal type is this?). Feb 20, 2016 at 12:58
  • @ThomasDickey, by verify you mean something like cat? Then yes, it does echo that code. Anyway, it's not a physical key, actually. As you surely know, in modern terminals (like iTerm on OS X) you can define your own escape sequences for a key or a keys combination. So, I've done that, and now I'm trying to make it work in bash (as it already works in Vim). But somehow - as described above - with no success, unfortunately. Any suggestions, may be? Thanks!
    – A S
    Feb 20, 2016 at 18:47
  • Since it works-in-Vim, I assume you got the escape character mapped. But that (literal \e versus escape character) is a detail that might go awry, since your sentence mentioning <F18> has no escape character. Feb 20, 2016 at 20:11

1 Answer 1


In iTerm2 add the following binding (to send hex codes) on <F18> keydown: 0x1b 0x5b 0x31 0x3b 0x35 0x51.

The issue is that your test with cat is misleading. Here's the proper test: cat | xxd. Try before and after adding the hex code rule.

0x1b : escape byte (rendered as ^[)
0x5b : [
0x31 : 1
0x3b : ;
0x35 : 5
0x51 : Q

These are the bytes your inputrc is expecting.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .