dotfiles/zsh/history.zsh
Thomas Preisner 8e51223d86 zsh: history: move relevant setopts into history.zsh
Also don't share history between terminals instantly.
2017-07-10 03:00:17 +02:00

49 lines
1.6 KiB
Bash

# ===== setopts
# allow multiple terminal sessions to all append to one zsh command history
setopt append_history
# save timestamp of command and duration
setopt extended_history
# add commands as they are typed, don't wait until shell exit
setopt inc_append_history
# when trimming history, lose oldest duplicates first
setopt hist_expire_dups_first
# do not write events to history that are duplicates of previous events
setopt hist_ignore_dups
# do not add command lines to history that start with a space
setopt hist_ignore_space
# when searching history don't display results already cycled through twice
setopt hist_find_no_dups
# remove extra blanks from each command line being added to history
setopt hist_reduce_blanks
# don't execute, just expand history
setopt hist_verify
# ===== 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