Sun Dec 27 2020·1 min read
Photo by Anelale Nájera
Many people know about the shell functionality that when you press the up or down arrow keys you navigate back and forth between commands you've previously used.
However there's a couple of lines you can add to your
to improve this functionality - when you start typing a command i.e.
press the arrow keys you only navigate between commands you've previously used
that start with
In order to enable this, in your
.bashrc add the following lines:
bind '"\e[A": history-search-backward' bind '"\e[B": history-search-forward'
Alternatively if you use zsh add the following lines to your
bindkey '\eOA' history-beginning-search-backward bindkey '\e[A' history-beginning-search-backward bindkey '\eOB' history-beginning-search-forward bindkey '\e[B' history-beginning-search-forward
Source your shell so the updated config takes effect, i.e.:
and start filtering your command history based on input. Start typing a command
cd and press the up and down arrows to navigate between previously typed
in commands that match the filter