/etc/inputrc: Explanation & Insights
What Is /etc/inputrc
?
The /etc/inputrc
file is a configuration file in Linux that determines how user input from the keyboard is interpreted by the shell. This
file is read and used by the GNU Readline library, which offers customizable command-line interfaces for many shells and utilities such as bash, python, and
many more.
Why Is /etc/inputrc
Important?
As a Linux user, you spend most of your time in the shell, typing commands, navigating directories, and manipulating files.
The /etc/inputrc
file plays a key role in making this interaction more user-friendly and efficient. It allows you to customize keys or sequences of keys, so
you can create your own keyboard shortcuts or change the default settings to suit your needs.
Content of /etc/inputrc
The content of the /etc/inputrc
file consists of a series of settable readline variables and key bindings. Here's an example of what the contents might look
like:
# /etc/inputrc - global inputrc for libreadline
# See readline(3readline) and `info rluserman' for more information
# Be 8 bit clean.
set input-meta on
set output-meta on
set convert-meta off
# To allow the use of 8bit-characters like the german umlauts, uncomment
# the line below. However this makes the meta key not work as a meta key,
# which is annoying to those which don't need to type in 8-bit characters.
# set convert-meta on
# try to enable the application keypad when it is called. Some systems
# need this to enable the arrow keys.
# set enable-keypad on
# see /usr/share/doc/bash/inputrc.arrows for other codes of arrow keys
# do not bell on tab-completion
# set bell-style none
# set bell-style visible
This example shows some of the readline variables that can be set in the /etc/inputrc
file.
How to Use /etc/inputrc
The /etc/inputrc
file can be edited using a text editor like nano
, vi
, or emacs
. You can open it with the following command:
sudo nano /etc/inputrc
You can then add or modify the key bindings or variables as per your needs. For instance, if you want to disable the bell sound that rings when you press Tab
for auto-completion, you can uncomment the line # set bell-style none
by removing the #
at the front of the line.
Typical Problems Related to /etc/inputrc
If you experience issues with your keyboard input not behaving as expected in the shell, it could be due to incorrect settings in the /etc/inputrc
file. For
example, if the arrow keys are not working to navigate through the command history, it could be because the enable-keypad
setting is turned off.
Conclusion
In conclusion, the /etc/inputrc
file is a powerful tool that allows you to customize your keyboard input in the shell. By understanding
and correctly using this file, you can significantly enhance your productivity and efficiency when working on a Linux server.