Searching through history with up and down arrow in zsh

zsh

When I first switched to ZSH when I would use the up arrow key to move through history it would filter the history based on what I had already typed so if I type mysql and then up I would be stepping through recent commands that started with mysql.

This is no longer the case, now if I use up it just steps thought the most recent commands regardless of what I've already typed. How can I turn this back on?

My .zshrc is very small and I've already tried turning all my options off.

Here is what is in my .zshrc

plugins=(git command-not-found svn debian screen vi-mode)
source $ZSH/oh-my-zsh.sh

bindkey -v
bindkey "^R" history-incremental-search-backward
export EDITOR="vim"

# history stuff
HISTFILE=~/.zsh-histfile
HISTSIZE=2000

Best Answer

You had up-line-or-search bound to your up-arrow. This should do what you want:

bindkey '^[[A' up-line-or-search
bindkey '^[[B' down-line-or-search

[Edit]:

The command above only uses the first word to search. The following will use the whole line. See man zshcontrib...

autoload -U up-line-or-beginning-search
autoload -U down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey "^[[A" up-line-or-beginning-search # Up
bindkey "^[[B" down-line-or-beginning-search # Down
Related Question