I am new to the unix system, and find it interesting to create customized functions and configurations in the setting files like .bashrc and .inputrc.

However, I don't understand the differences between the two. For example, when I created alias, I put them in .bashrc.

Example 1: alias ...='cd ../../'

When I create operations like using arrow key to look for previous or next command, I put the command in .inputrc.

Example 2: "\e[A": history-search-backward

Why I need to put them in different setting files? How do I distinguish when to put what where?

Thank you in advance!


Settings that are in the .inputrc file affect all programs that use the GNU readline library, not just bash. Think of the .inputrc file as being a configuration file for GNU Readline similar to how .bashrc is a configuration file for bash.

GNU Readline is described as:

... A set of functions for use by applications that allow users to edit command lines as they are typed in.

To clarify a bit further, settings that are in the .bashrc file only affect bash. If you'd like to optionally run bash without GNU Readline support or usage, you can invoke bash with the --noediting option as follows: bash --noediting. You can find out more about bash options here.

To answer your last question of

How do I distinguish when to put what where?

If you'd like an option to affect all programs on your system that use the GNU Readline library, .inputrc would be the prime choice. Elsewise, if you simply want to configure your bash session, .bashrc would be the best choice.

  • Thank you @aliceinpalth. Do you mean bash belongs to GNU Readline library? What else is in GNU Readline library? – Counter10000 Feb 15 '18 at 21:27
  • 5
    @Counter10000 In this sense, library isn't "a collection of tools" (I can see why you might think that) but "a lump of functionality that different tools can use". In this case, it's functions for working with a command line (including scrollback, line editing, and so on). Bash uses this for the shell prompt. On my system right in front of me, it's also used for bc (command line calculator), xfsprogs (filesystem admin programs), sqlite (a very small database system), lftp (a command-line ftp client), and more. – mattdm Feb 15 '18 at 21:34
  • 1
    No problem @Counter10000! I'm glad to help. @mattdm answered your question very well. To learn more about how these programs utilize GNU Readline, there's a good write-up available here. – aliceinpalth Feb 15 '18 at 22:16
  • 1
    it seems that the last paragraph in your answer is at least inaccurate. I suppose there are some options, which can be set only in the inputrc file, so the two files are not completely "interchangeable". I tried to set the options from this answer in .bashrc and nothing happened. They only have effect being set in .inputrc – Dmitry Koroliov Nov 5 '18 at 18:01

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.