For bash, I would to modify the tab key for completion to the escape key. I know that key bindings are defined in /etc/inputrc.

But I don't know if something like this could work:

`"\e" : complete`

I want to do that because my users were from Solaris where the escape key does the auto-completion.


Yes, it is possible to change the key binding or add key bindings to the complete function. This function is typically bound by default to Tab (which is the same as Ctrl+i) and Esc followed by another Esc. However, it is not possible to bind the Esc key by itself to any Readline function. This is because the Esc key is special and serves a couple of specific purposes in Readline.

The Esc key is used as a prefix for other key sequences, so entering an Esc by itself is only setting up the initial part of a full key sequence recognized by Readline. To see the list of all Esc-prefixed sequences recognized in bash, for example:

bind -p | grep '"\\e'

Because of the way Unix terminals are handled, an Esc-prefixed key sequence is usually the same as an Alt-key combination. So Esc followed by u is exactly the same as Alt+u.

The Esc key is also used to exit out of Readline's interactive history search mode.

  • So you say it is not possible to use Esc for the completion instead of Tab in a bash shell ? And it is the only key that i can't bind to the completion function ? – antoine4790 May 2 '14 at 8:37
  • It is not possible to bind Esc by itself, correct. But it is not the only key. For example, you could not bind the Ctrl key by itself to anything, Ctrl is only useful in combination with other keys. – Mike Miller May 2 '14 at 12:27

Double pressing escape has the same effect as single pressing tab. In this way, escape is already configured for completion.

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.