zsh: history: add improved history search functionality
This commit is contained in:
parent
f5bb986514
commit
7c64d5a801
1 changed files with 25 additions and 0 deletions
|
|
@ -2,3 +2,28 @@
|
|||
HISTSIZE=1000000
|
||||
SAVEHIST=1000000
|
||||
HISTFILE=~/.zsh/zsh_history
|
||||
|
||||
# ===== functions
|
||||
# vim-like completion of previous executed commands. Depending on cursor
|
||||
# position it either behaves like cursor up/down or includes already typed
|
||||
# text.
|
||||
zle -N zshrc-vi-history-beginning-search-backward
|
||||
zshrc-vi-history-beginning-search-backward()
|
||||
{
|
||||
local not_at_beginning_of_line
|
||||
if [[ $CURSOR -ne 0 ]]; then
|
||||
not_at_beginning_of_line=yes
|
||||
fi
|
||||
|
||||
zle history-beginning-search-backward
|
||||
|
||||
# start Vi-mode and stay at the same position (Vi-mode moves one left,
|
||||
# this counters it).
|
||||
zle vi-cmd-mode
|
||||
if [[ -n $not_at_beginning_of_line ]]; then
|
||||
zle vi-forward-char
|
||||
fi
|
||||
}
|
||||
|
||||
# only ^P bind is necessary as ^P enters Vi-Mode and ^N only makes sense after calling ^P
|
||||
bindkey '^P' zshrc-vi-history-beginning-search-backward
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue