How do I reload .inputrc?

103

28

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?

Captain Lepton

Posted 2011-02-03T11:31:14.843

Reputation: 1 520

Simply restart Bash. – Kusalananda – 2016-06-20T14:16:14.877

@Kusalananda, it seems that you have not read the question properly "How can I reload this after editing to see the changed behaviour without restarting my terminal program?" – Captain Lepton – 2016-06-21T09:19:44.330

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 – 2016-06-21T09:22:27.490

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 – 2016-06-21T13:25:30.030

1Yes, 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 – 2016-06-21T13:36:30.563

8Background (not wrong). – Paused until further notice. – 2011-02-03T16:03:13.450

Is there a way to call Readline to reload the history? Like xmonad ----recompile && xmonad --restart for reloading XMonad? – Ehtesh Choudhury – 2012-04-19T00:56:13.600

3

I came here looking for how to load .inputrc with a command. http://superuser.com/q/419670/56544

– dfrankow – 2013-02-22T17:23:25.350

Answers

82

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

See the Bash Reference Manual for explanation.

maxelost

Posted 2011-02-03T11:31:14.843

Reputation: 2 191

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 – 2018-03-23T10:06:02.730

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 – 2019-01-19T12:59:44.063

4This 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 – 2011-02-08T12:36:29.673

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 – 2011-04-25T10:45:10.923

57

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

studgeek

Posted 2011-02-03T11:31:14.843

Reputation: 1 805

1I 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 – 2019-10-13T09:12:49.310

15

rofrol

Posted 2011-02-03T11:31:14.843

Reputation: 1 419

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.

Antonio Bardazzi

Posted 2011-02-03T11:31:14.843

Reputation: 286