Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 12 down vote accepted
bindkey "^[[5~" history-beginning-search-backward

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

This is what I use

share|improve this answer
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 '12 at 7:54
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 '12 at 17:28
@yuyichao, did you perhaps find how to make zsh behave like bash? – Blaz Aug 23 '15 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 '15 at 20:12

You must log in to answer this question.

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