使 zsh 历史搜索的行为类似于 bash reverse-i-search

Sem*_*ime 5 search bash zsh command-history

  • bash中,按[CTRL]+[r]将打开reverse-i-search提示符。
  • 如何以类似的方式搜索 zsh 历史记录?

注意:搜索查询将仅命中完整命令的中间,而不是正常 zsh 搜索所需的开头匹配。

Sem*_*ime 5

要使zsh在按 时表现得像 bash[CTRL]+[r]

# for non-pattern search like in bash 
bindkey "^R" history-incremental-search-backward`
Run Code Online (Sandbox Code Playgroud)

或者

# for pattern search (the wildcard `*` will use zsh completion)
bindkey "^R" history-incremental-pattern-search-backward
Run Code Online (Sandbox Code Playgroud)

注意:将该行添加到您的~/.zshrc以使其永久化。