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!
Best Answer
Settings that are in the
.inputrc
file affect all programs that use the GNU readline library, not justbash
. Think of the.inputrc
file as being a configuration file for GNU Readline similar to how.bashrc
is a configuration file forbash
.GNU Readline is described as:
To clarify a bit further, settings that are in the
.bashrc
file only affectbash
. If you'd like to optionally runbash
without GNU Readline support or usage, you can invokebash
with the--noediting
option as follows:bash --noediting
. You can find out more aboutbash
options here.To answer your last question of
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 yourbash
session,.bashrc
would be the best choice.