zsh: Enable incremental backward search cycling

Previously enabled the search through shell history with ^r on the
commandline. This is still the case, though now the results of the
search can be cycled through with ^p (earlier) and ^n (later).

The key combinations are only active in incremental search and will only
search through the previous results.

When in normal more, or command mode, ^p/^n will cycle through the
history of the shell, taking into account what has already been typed
and going through the history on the basis of this.
This commit is contained in:
Marty Oehme 2020-11-06 15:08:47 +01:00
parent 0e34af1992
commit 201cd58f3f
Signed by: Marty
GPG key ID: B7538B8F50A1C800

View file

@ -167,10 +167,14 @@ bindkey -a '^[[3~' delete-char
# always allow removing words with <c-w>
bindkey -a '^w' backward-kill-word
# enable cycling through previous commands with <c-p/n>
bindkey '^P' up-line-or-history
bindkey '^N' down-line-or-history
bindkey '^P' history-beginning-search-backward
bindkey '^N' history-beginning-search-forward
# search history backwards <c-r>
bindkey '^r' history-incremental-search-backward
# cycle through history results
bindkey -M isearch '^P' history-incremental-search-backward
bindkey -M isearch '^N' history-incremental-search-forward
# Send command to editor and back for execution
zle -N edit-command-line