【发布时间】:2017-08-14 13:00:40
【问题描述】:
我非常喜欢在 bash 中使用 readline 的 history-search-forward 和 history-search-backward。我的.inpurc 中有以下内容:
# Scroll through matching history with up and down keys
"\e[A":history-search-backward
"\e[B":history-search-forward
并使用向上和向下键滚动浏览我历史记录中的匹配命令。
但是,当我启用 vi 模式时,它似乎停止了历史搜索工作。我已经这样配置了 vi 模式(也在 .inputrc 中):
# Enable vi mode
set editing-mode vi
set keymap vi-command
# insert/command mode indicator:
set show-mode-in-prompt on
# Indicator formatting in prompt:
set vi-cmd-mode-string "\1\e[0;34m\2[\1\e[0m\2C\1\e[0;34m\2]\1\e[0m\2 "
set vi-ins-mode-string "\1\e[0;34m\2[\1\e[0m\2I\1\e[0;34m\2]\1\e[0m\2 "
当我从.inputrc 中删除与 vi 模式相关的行时,历史搜索工作正常。当我把它们放回去时,它就坏了。
有没有办法同时启用这两个功能?
我在 OSX Sierra 上使用通过自制软件安装的 GNU Bash 4.4.12。
【问题讨论】:
-
我投票结束这个问题,因为它不是一个编程问题,所以更适合U&L
标签: bash shell command-line vi readline