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. (:

Tags: , ,

38 Responses to “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. If ~/.inputrc doesn’t work, then you need to add

    export INPUTRC=~/.inputrc

    to your .bashrc/.bash_profile/wherever.

  3. Marius, thanks for the tip!

  4. Colin Marquardt says:

    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

  5. Colin Marquardt says:

    FWIW, the error is

    faultCode0faultStringFatal error:Cannot access empty property in /home/garrett/sites/ on line 154

  6. Jimmy says:

    Yes, finally! I’ve been looking for this. Well, not that active lately, but it’s been in my mind to fix this. Thanks!

  7. I acutally go the whole hog and do like 4dos used to.
    I.E. have the up/down arrows do the search.
    Note if you don’t type anything the up/down arrow behave as before.

  8. Wouter says:

    Yes you need to escape with a \\ before the first e. Doesn’t seem to work in my xterm (debian) though.. 🙁

  9. Wouter says:

    Yes you need to escape with a ‘\’ before the first e. Doesn’t seem to work in my xterm (debian) though.. 🙁

  10. Anonymous says:

    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.

  11. […] Super-useful inputrc enables you to CTRL-left and CTRL-right through your current command line, just like in the good ol’ DOS days! […]

  12. Francesco says:

    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 !!

  13. Jason says:

    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.

  14. ameet says:

    how to make readline auto compleate search the words to be compleated from the file.

  15. Triffid Hunter says:

    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.

  16. micha says:

    I noticed what appears to be a bug in readline. I’m using 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.

  17. nix says:

    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?

  18. Will says:

    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.

  19. kortina says:

    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?

  20. Bryan Harris says:


    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.

  21. omega says:

    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 🙂

  22. Rich says:

    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"

  23. kwilliam says:

    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

  24. Binny V A says:

    Thanks for this post. If possible, can you and some comments to show which keys you are using? I know [5~, [6~ is Page up/Page down – but the rest have me a bit confused.

  25. andre says:

    Debian has a file explaining this:

    # 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

  26. […] ##helpful sites#———————————–EOF […]

  27. Ryan says:

    You don’t need to read docs to find the key codes. Just use “showkey -a”.

  28. Anonymous says:

    HELP! =) how do i discover the symbols that represent key combinations like

  29. […] Linux initrc file page shows a common initrc for Linux, and Garrett LeSage writes about a few super-useful inputrc […]

  30. Jim says:

    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.

  31. use this link

    Linuxart » Blog Archive » Super-useful inputrc

  32. I enjoyed every little piece of the post and I have favorited your website.

  33. Aw, this is a really nice post. Taking time and actual effort to make a very good article is very rare today!

  34. I discovered this blog in Bing and read a couple of of your early posts. Keep up the good job.

  35. This article has really peaked my interest. I’m going to bookmark your site and keep checking for brand new information.

  36. "I use humor to cover up my endless sadness" Really doesn’t sound as good as when it has seemingly in Seemingly makes it less of a flat statement and creates the idea that he is not exaggerating his pain as much he is struggling to deal with If you remove "seemingly" it becomes just a statement and an exaggerated one by leaving in the word If we tried "I use humor to cover up my sadness" that doesn’t work either as it’s just a plain By adding in "seemingly endless" the 2 words work with each other to change the sentence from just sad statement to something a little more open ended as "seemingly" adds a level of uncertainty and "endless" a level of So by making it "I use humor to cover up my seemingly endless sadness" the artist has left potential freedom in the interpretation of how sever the situation is, and that’s when the fox comes The fox is intentionally out of place with such a sentence but at the same time clearly It is the fox that creates a backdrop of positivity that allows for the juxtaposition of the sentence to develop into comedy but without a level of freedom in the text it would be harder for viewers to see the humor intended in the sentence as it becomes less A cute fox with an ironic statement needs flexibility to become something more than just And that’s how you bullshit your way through a visual arts

  37. Hi there colleagues, its great piece of writing concerning tutoringand completely explained, keep it up all the time.

  38. ở đây says:

    I was suggested this web site through my cousin. I’m no longer positive whether or not this submit is written by means
    of him as nobody else recognize such specified about my problem.
    You’re wonderful! Thank you!

Leave a Reply