Skip to content
Afa' Afa'

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

txt
# Enable backward/forward search history
"\e[A": history-search-backward
"\e[B": history-search-forward
Something wrong or want to discuss this article? Get in touch

Search articles and projects

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