Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
    
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 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. –  mtmiller May 2 at 12:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.