In Oh My Zsh, by default, the history feature matches prefixes.
Typing ls
and hitting Up Arrow will scroll through commands that start with what you typed: matching ls
and ls -l
but not echo ls
.
In Prezto, by default, the history feature matches anywhere in the string.
Typing ls
and hitting Up Arrow will scroll through commands that contain what you typed: matching ls
and ls -l
and also echo ls
.
Is there a way to set Prezto to match prefixes only, like the Oh My Zsh default behaviour?
(According to the history-substring-search
documentation, setting HISTORY_SUBSTRING_SEARCH_PREFIXED=1
will do this, but I have this set in .zshrc
and it still matches anywhere in the string.)
I have now found that instead of using whatever plugin comes with Prezto, it is possible to use built-in zsh features instead.
Add the following to the end of ~/.zshrc
:
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
bindkey "^[[B" down-line-or-beginning-search