Probably something like
# ~/.inputrc
"e[A": history-search-backward
"e[B": history-search-forward
or equivalently,
# ~/.bashrc
if [[ $- == *i* ]]
then
bind '"e[A": history-search-backward'
bind '"e[B": history-search-forward'
fi
(the if statement checks for interactive mode)
Normally, Up and Down are bound to the Readline functions previous-history
and next-history
respectively. I prefer to bind PgUp/PgDn to these functions, instead of displacing the normal operation of Up/Down.
# ~/.inputrc
"e[5~": history-search-backward
"e[6~": history-search-forward
After you modify ~/.inputrc
, restart your shell or use Ctrl+X, Ctrl+R to tell it to re-read ~/.inputrc
.
By the way, if you're looking for relevant documentation:
Bash uses The GNU Readline Library for the shell prompt and history.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…