4

I read on a blog somewhere about the possibility to use automatic history expansion before actually executing a command or even pressing the enter key in the command line. It involves the 'magic-space' and creating an ~/.inputrc configuration file.

What should that file contain exactly and when is it read (in login and non-login bash shells)?

4

Per the blog command you just need:

$if Bash
  Space: magic-space
$endif

The rest (the default settings) are sitting in /etc/inputrc.

This is read when GNU Readline (the input library Bash uses) is started. Because it's not directly part of Bash, reset and source ~/.bashrc et al won't work. To reload this without starting a new session, you need to run bind -f ~/.inputrc.

  • Very nice indeed. It works very well and makes the ~/.bashrc shell option -- shopt -s histverify -- redundant. Thank you. – Cbhihe Jun 10 '14 at 12:14
  • 1
    Great answer for additionally wrapping the binding in an if to protect other shells that use readline such as PostgreSQL and SQLite. – Travis Clarke Sep 29 '17 at 19:05

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.