Super-useful inputrc

You either want to place the following in ~/.inputrc or /etc/inputrc… I’ve found that while ~/.inputrc works sometimes, it doesn’t on all systems.


"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
"\e\e[C": forward-word
"\e\e[D": backward-word
set completion-ignore-case On

All lines except the last enable nice readline & bash cursor movement (control + arrow keys and what not) while the last line turns on case insensitivity for tab-completion, enabling you to have folders and files of mixed case characters while not having to type the capital letters. (You can have a directory called “Documents” and tab-complete by tying “doc<tab>

I’ve been enjoying the above for a while now, and I think it really should be the default settings for distributions.

Note: This works for Linux, Mac OS X, and *BSD. It might work for people using Bash on Windows, but you’re on your own there. (:

31 thoughts on “Super-useful inputrc

  1. With one change that’s a very nice default configuration.

    “\e[5~”: history-search-backward
    “\e[6~”: history-search-forward

    This maps Page Up / Page Down to the IMO very useful history search function. Configured like that by default in paldo.

  2. These should all be “quote-backslash-e…”, right? The backslash is missing for me.

    I have a few more variables set:

    set bell-style visible
    set expand-tilde on
    set convert-meta off
    set input-meta on
    set output-meta on
    set show-all-if-ambiguous on
    set visible-stats on

  3. FWIW, the error is

    faultCode0faultStringFatal error:Cannot access empty property in /home/garrett/sites/linuxart.com/site/log/wp-content/plugins/SK2/sk2_comment_class.php on line 154

  4. Works great in gnome-terminal; thanks!

    I also tried to get Control-Backspace to do unix-filename-rubout, but unfortunately it seems that Control-Backspace doesn’t look any differently from Backspace.

  5. Pingback: Holy Shmoly! :: Bash Fun - history and navigation

  6. for those who like the WinNT/XP way TAB works in MSDOS prompts (i.e. instead of showing a list of possible completions like bash does on default, TAB cycles through possible completions), just add this to .inputrc:

    “\t”: menu-complete

    it saves me a lot of typing !!

  7. Anybody know how to make a shortcut so that way when i press “ctrl+a” or whatever letter, i can set it to do an action…i was told it was with the /etc/inputrc file, but i can’t figure it out.

  8. I had to add:
    “\e[1;5C”: forward-word
    “\e[1;5D”: backward-word
    on my (gentoo linux) system for word search to work. A similar translation should apply nicely to the others.

  9. I noticed what appears to be a bug in readline. I’m using Terminal.app on tiger with bash, and doing ‘set completion-ignore-case On’ causes completion to break with directories that have spaces in the name. For example:

    /home/micha/Documents/My Stuff/myfile.pdf

    If, from /home/micha I do

    ls documents/my\ [TAB]

    it completes correctly to produce Documents/My\ Stuff/ but if I press tab again at that point it produces this:

    ls Documents/My\\\ Stuff

    which is wrong.

  10. One simple question:

    How does the keyseq get generated? Are they predefined values? Do they relate to the ansi key set?

    IE: “\e[3~”: delete-char
    How does the value: “\e[3~”: relate to the delete key?

  11. Q: How does the value: “\e[3~”: relate to the delete key?

    A: “\e[3~” is the sequence of bytes that your terminal sends when the delete key is pressed. And when I say “terminal”, I mean either a real serial terminal, or an xterm-like thing, or the Linux console driver.

  12. Does this work with iterm in os x? I copied and pasted

    “\e[1~”: beginning-of-line
    “\e[4~”: end-of-line
    “\e[5~”: beginning-of-history
    “\e[6~”: end-of-history
    “\e[3~”: delete-char
    “\e[2~”: quoted-insert
    “\e[5C”: forward-word
    “\e[5D”: backward-word
    “\e\e[C”: forward-word
    “\e\e[D”: backward-word

    into my ~/.inputrc and tried doing export INPUTRC=~/.inputrc but forward and backword word do not work for me. Anyone got any suggestions?

  13. Hi,

    I think there is a man page, or an info page, or some kind of document in my system somewhere which tells me how the escape sequences work. Does anybody know where that file is at? I am using Slackware 12.0, and I thought I had seen that file before.

  14. kortina: if you typed “export INPUTRC=~/.inputrc” into your terminal that just sets the variable, doesn’t actually read the file. you either have to type it in your ~/.bash_profile or just put those settings in /etc/inputrc instead of locally.

    oh, i’m not sure about if it works with iterm, i just use the Terminal in leopard (works just fine for me, i’ve yet to find something that iterm does and Terminal doesn’t – besides fullscreening which i don’t like anyway)

    but yes, it does work with mac os x :)

  15. Whoops. Looks like somebody’s blog is converting double quote characters into posh quotes. Notice how there’s a difference between “these quotes” and "these"

  16. Thank you blog author and Marius Gedminas!
    After much fruitless searching, I have finally gotten the console to use a visible bell instead of beeping loudly.

    I added line
    set bell-style visible
    to ~/.inputrc
    and added line
    export INPUTRC=~/.inputrc
    to ~/.bashrc

  17. Debian has a file explaining this:

    /usr/share/doc/bash/inputrc.arrows:
    # This file controls the behaviour of line input editing for
    # programs that use the Gnu Readline library.
    #
    # Arrow keys in keypad mode
    #
    “\C-[OD” backward-char
    “\C-[OC” forward-char
    “\C-[OA” previous-history
    “\C-[OB” next-history
    #
    # Arrow keys in ANSI mode
    #
    “\C-[[D” backward-char
    “\C-[[C” forward-char
    “\C-[[A” previous-history
    “\C-[[B” next-history
    #
    # Arrow keys in 8 bit keypad mode
    #
    “\C-M-OD” backward-char
    “\C-M-OC” forward-char
    “\C-M-OA” previous-history
    “\C-M-OB” next-history
    #
    # Arrow keys in 8 bit ANSI mode
    #
    “\C-M-[D” backward-char
    “\C-M-[C” forward-char
    “\C-M-[A” previous-history
    “\C-M-[B” next-history

  18. Pingback: Doskey like tab completion and various other fixes /power user hacks for the mac console prompt (ctrl-left,right arrow) « Matt Brown – Journeys of a software engineer

  19. Pingback: Enable Autocomplete for root on Mac OS X « Surnia Ulula

  20. On osx use the read command to figure out your keys, for control+left-arrow I get “^[[1;5D” and then use “”\e[1;5D” in my inputrc. See ‘man bash’ for the various escape sequences and functions if you need more info.

  21. Pingback: colon cleansing teas

Leave a Reply