History-search-backward working differently in zsh than in bash

zsh

I have history-search-backward mapped as PageUp.

When I type:

git push <PageUp><PageUp><PageUp>
  1. in Bash it begins to cycle through all history entries beginning with git push
  2. in Zsh it begins to cycle through all history entries beginning with git so it will list entries such git status, git remote update etc. This is not what I want.

How can I have zsh behave like bash? What setopt should I set?

Best Answer

Bind the history search of zsh to [Page UP] and [Page Down]

bindkey "^[[5~" history-beginning-search-backward
bindkey "^[[6~" history-beginning-search-forward

Bind the history search of zsh to [UP] and [Down]

bindkey "^[[A~" history-beginning-search-backward
bindkey "^[[B~" history-beginning-search-forward
Related Question