Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm on a roll today, here's another question:

How come when I put these into .inputrc, they both do the same thing?

TAB: menu-complete
Shift-TAB: menu-complete-reverse

i.e. they both do whatever the last one says.

share|improve this question
up vote 9 down vote accepted

Readline doesn't know anything about a modifier called Shift, and quietly ignores unknown modifier names. Try wibble-TAB.

To bind an action to Shift+Tab, you need to find out what escape sequence your terminal sends. In bash, run cat and type Ctrl+V then Shift+Tab. This will insert the escape sequence literally. It's likely that the first character will be an escape character, shown as ^[; different terminals have different escape sequences, but common possibilities are ␛[Z (i.e. escape, left bracket, capital Z) and ␛␉ (i.e. escape, tab). Bind the key appropriately in ~/.inputrc (where \e means an escape character).

"\e\t": menu-complete-backward
"\e[Z": menu-complete-backward
share|improve this answer
Ah, ^[Z worked for me (BASH); thanks for the detailed answer! :) – Mehrdad Jul 19 '11 at 22:17
Do you press Enter before or after 'cat'? Why is 'cat' needed? I seem to get the same escape sequences without 'cat'. – dougkramer Nov 5 '14 at 18:14
@douglas.kramer Running cat avoids any bash binding. Usually bash has the same Ctrl+V binding to insert the next character literally so it doesn't make a difference. – Gilles Nov 5 '14 at 18:20
I'm having trouble getting Shift+Tab to bind to 'shell-expand-command'. I get: $ cat <Enter> <Shift+Tab> which displays ^[[Z Do I always add \e ahead of the sequence I get from Ctrl+V? Does this translate to: "\e^[[Z": shell-expand-command – dougkramer Nov 5 '14 at 18:34
@dou Replace ^[ by `\e` – Gilles Nov 5 '14 at 20:03

Your Answer


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.