2

Is it possible when I press Ctrl+r and after this, for example, press the letter a, then using the up and down arrow key to search only the commands in the history that start with a? Or if I type ssh and then use the arrow keys to search commands that start with ssh.

Is there a script that can implement this?

1 Answers1

3

You can even avoid the need of typing Ctrl+r by adding these two lines to your ~/.inputrc:

"\e[A": history-search-backward
"\e[B": history-search-forward

Up and down arrows will continue to browse your history if you press them at the bash prompt. But it will search for a command starting with the text to the left of the cursor if you type the beginning of a command like ssh.