dotfiles/zsh/history.zsh

29 lines
819 B
Bash

# ===== History
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