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?

1 Answer 1


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
  • If you want that the same functionality but with Up and Down arror, replace the binding key "^[[5~" to "^[[A" and "^[[6~" to "^[[B"
    – millisami
    Apr 9, 2012 at 7:54
  • 1
    zsh's history-beginning-search still have a subtle difference from bash(readline)'s history-search. readline's command is equivalent to history-backward/forward (and put the cursor at the end of the line) before u move the cursor in the line (which will make it turns into "history-beginning-search") while zsh's ones always put the cursor at the beginning of the line. Is there a easy way to change this behavior without writing a new widget? THX
    – yuyichao
    Aug 7, 2012 at 17:28
  • @yuyichao, did you perhaps find how to make zsh behave like bash?
    – Blaz
    Aug 23, 2015 at 14:44
  • @courteous Not really, Although I'm getting used to the zsh behavior after using it for some time... Especially since a simple <C-e> can turn the zsh behavior to the bash behavior but not so easy the other way around.
    – yuyichao
    Aug 23, 2015 at 20:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .