Accessing the bash history with arrow keys

After saving the bash history appropriately (as described in the previous post Bash history – how to get the most out of it) you will also want to make sure that working with the history during the session is as easy as pie. For that you will have to adjust the .inputrc file.

Traditionally the terminal/console would emulate all kinds of behaviors depending on your historical terminal access to the computer/mainframe. This unfortunately led to a combinatoric explosion of possible key events and configurations, which makes the successful configuration of the .inputrc rather tedious and annoying.

All I wanted is to use the arrow keys as well as page up and page down, home and end to navigate the commands and the history.

The bash can do that, no doubt, several decades of programming knowledge have been distilled in it, but making it behave according to my needs, well, that was a matter of patience.

The .inputrc-file contains all the key-stroke specific information to make sure the bash behaves as you want it to. Unfortunately, the syntax of the the key-stroke pattern is completely brain-dead. This is why I’m trying to reproduce here as many of the keys as possible, just so that I don’t have to go on another Internet odyssey to find them all.

Continue reading

Bash history – how to get the most out of it

One of the major annoyances when moving to a new system is to make everything as comfortable as on the old one. The major work horse for many Linux programmers and system administrators is of course the shell – in particular the bash. While being extremely useful, I always need quite some time until I have it working just right, so that it doesn’t stand in the way of doing productive work. No Linux system I have installed so far had (for me) satisfactory default values of the bash resource file .bashrc.

As I am relying heavily on the bash, in particular on the history of commands typed, this is usually the first thing to adjust. bash has quite some options how to fine-tune the history:

HISTCONTROL:
By specifying one or more parameters you can define how the commands will be entered into the history file.

Continue reading