History backward/forward search

Bind the up and down arrows to prefix search in Bash with a small .inputrc fragment.

1 min read Updated

By default Bash searches the whole history for the current line. This .inputrc fragment rebinds the up and down arrows to prefix search, so typing the beginning of a command is enough to cycle through matching entries. Add the lines to ~/.inputrc and start a new shell.

Enable backward/forward search history

.inputrc

text
# Enable backward/forward search history
"\e[A": history-search-backward
"\e[B": history-search-forward

Search articles

Type to filter articles. Use the arrow keys to move through results and Enter to open one. Press Escape to close.