87

Background

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.

Question

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

  • 8
    Background (not wrong). – Dennis Williamson 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
80

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

See the Bash Reference Manual for explanation.

  • 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 at 12:59
48

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).

14

This worked for me

bind -f ~/.inputrc

https://unix.stackexchange.com/questions/153357/inputrc-file-not-sourcing-correctly/246422#246422

10

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.

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.