I have heard that the readline module is reading ~/.inputrc and that is how it changes the behaviour of keystrokes under programs such as bash.


How can I reload this after editing to see the changed behaviour without restarting my terminal program?

  • 8
    Background (not wrong). – Paused until further notice. Feb 3 '11 at 16:03
  • 3
    I came here looking for how to load .inputrc with a command. superuser.com/q/419670/56544 – dfrankow Feb 22 '13 at 17:23
  • 1
    @CaptainLepton I saw that. The terminal is not the same as the shell. Doing exec bash in a Bash session will replace the current shell session with a new Bash session. xterm is a terminal. – Kusalananda Jun 21 '16 at 9:22
  • 1
    @Kusalananda Thanks for the clarification. That is a good idea. Would you perhaps describe running > exec bash as running a new shell in the current terminal rather than restarting bash, as you are replacing your previous executable? – Captain Lepton Jun 21 '16 at 13:25
  • 1
    Yes, there is no way of "restarting" the current shell session. This is one way of doing it. Using the solution that @maxelost gave is another. – Kusalananda Jun 21 '16 at 13:36

By default, C-x C-r is bound to re-read-init-file.

See the Bash Reference Manual for explanation.

| improve this answer | |
  • 4
    This doesn't work for me. I tried a different mapping in the .inputrc file and also no luck: "\eX\eR": re-read-init-file Any suggestions? – Captain Lepton Feb 8 '11 at 12:36
  • 6
    @Captain Actually, it does, except it does not clear keystrokes that were deleted in the meantime. If you e.g. add some, they are loaded. Your only solution for these is a new bash -l (shell that behaves like a login shell) that is freshly initialized. – Daniel Beck Apr 25 '11 at 10:45
  • I was editing /etc/inputrc but I had an almost empty ~/.inputrc that was preventing the one in /etc/ from being used. Removing ~/.inputrc caused it to read /etc/inputrc and make my changes active. – Malvineous Mar 23 '18 at 10:06
  • 1
    @Malvineous I've been caught out by that before.. if you add $include /etc/inputrc to the top of ~/.inputrc, it avoids this problem. – mwfearnley Jan 19 '19 at 12:59

You can also reload new entries from command line using bind -f ~/.inputrc. That will load the entries in .inputrc. Note that it just does a load, not a "reload" - so it doesn't reset any lines you happen to have removed from the .inputrc.

To quickly test from a clean slate, just run bash then work inside that new nested shell (or start a new terminal).

| improve this answer | |
  • 1
    I see, correct me if I'm wrong, that bind -f only really accepts a filename, and not a file, so something like bind -f <(echo 'one line with ~/.inputrc syntax') (or, trivially, bind -f <(cat ~/.inputrc)) will not work. This is a bit annoying. Do you know what could I do in this respect? – Enrico Maria De Angelis Oct 13 '19 at 9:12

This worked for me

bind -f ~/.inputrc


| improve this answer | |

In .inputrc first choose your binding and after bind the re-read-init-file function:

set editing-mode vi
"\C-x\C-r": re-read-init-file

Press CTRL and x, release both, press CTRL and r.

| improve this answer | |
  • This only works during initialization, i.e. for the editing mode you start the session with. If after this you change the edtiing-mode to emacs, then you won't get the keybinding. And AFAIK you need to fallback to the bind -f method. – Atralb Jun 8 at 23:13

The following snippet for ~/.inputrc will map C-x C-r in all keymaps (emacs, vim command mode and vim insert mode):

set keymap emacs
"\C-x\C-r": re-read-init-file

set keymap vi-command
"\C-x\C-r": re-read-init-file

set keymap vi-insert
"\C-x\C-r": re-read-init-file
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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