Quantcast

reverse-menu-complete in bash

Shag helped me add reverse-menu-complete to my bash setup. It’s really easy, but undocumented. To get shift-TAB to menu-complete backwards, add the following line to your .inputrc:
\C-y:"\M--\C-i"

The \M– is actually a -1 argument to menu-complete (aka TAB, aka Ctrl-I). The info for Readline arguments describes how to pass numeric args to readline commands.

Reverse-menu-complete is useful to me since I have a FingerWorks keyboard with gestures for tab and shift-tab. The gesture stuff saves a ton of typing, which is good if you have RSI.

Here is my full .inputrc:
\C-y:"\M--\C-i"
TAB: menu-complete
set completion-ignore-case On

5 Responses to “reverse-menu-complete in bash”

  1. matenko
    September 12th, 2006 | 3:03 am

    This is such a useful tip! - shame it does not work here… :-((

    I can type Alt+- and Ctrl+i manually and it works.

    But using the above entry in my inputrc I always get a question mark printed out when using Ctrl-y.

    I am using debian etch with libreadline5-5.1-7 and bash-3.1-5.

    Any hints how to get it work would be very much appreciated, thanks!

  2. September 12th, 2006 | 8:36 am

    Hmmm… are you logged in at console or through a terminal? If you are using a terminal, check the ‘alt sends meta’ setting in your terminal program.

    You can use ‘xev’ to debug keypress events, which might help.

    I suspect your problem might be due to the way your terminal program is mapping Alt to meta, but am a little unsure why it’s not working for you.. I wonder if ‘M–’ (two minus signs there) is actually entering a -1 arg in your case.

  3. Ryan
    February 26th, 2007 | 12:56 am

    Using “\e” to invoke the escape key (which is how the meta sequence is invoked on my non-meta-key-having keyboard)instead of “\M-” works for me:

    “\e[Z”: “\e-1\C-i”

  4. Pando
    May 13th, 2007 | 3:12 pm

    Thx Ryan!
    That really helped me out. :)

  5. November 27th, 2007 | 3:45 pm

    Thanks rajbot and Ryan. (Ryan’s version worked for me).

    Not having that was driving me nuts!

Leave a reply