bash命令根据历史记录补全

用zsh比较方便的一个功能是在找之前用过的命令时可以先输入一部分命令作为过滤条件,
比如,想找 docker run 开头的历史命令,只需要键入 docker run 然后按 进行选择。
但是在用服务器的bash时没有这个功能,每次按 都会把敲入一半的命令清除掉。 ctrl-r 也不是很好用。

解决方法很简单,~/.bashrc中添加两行:

bind '"e[A": history-search-backward'
bind '"e[B": history-search-forward'

https://wiki.archlinux.org/index.php/Bash#History_completion

原文地址:https://www.cnblogs.com/dylanchu/p/9795663.html