HISTFILE="$HOME/.zhistory"
HISTSIZE='10000'
SAVEHIST="${HISTSIZE}"

setopt BANG_HIST                 # Treat the '!' character specially during expansion.
setopt EXTENDED_HISTORY          # Write the history file in the ':start:elapsed;command' format.
setopt INC_APPEND_HISTORY        # Write to the history file immediately, not when the shell exits.
setopt SHARE_HISTORY             # Share history between all sessions.
setopt HIST_EXPIRE_DUPS_FIRST    # Expire a duplicate event first when trimming history.
setopt HIST_IGNORE_DUPS          # Do not record an event that was just recorded again.
setopt HIST_IGNORE_ALL_DUPS      # Delete an old recorded event if a new event is a duplicate.
setopt HIST_FIND_NO_DUPS         # Do not display a previously found event.
setopt HIST_IGNORE_SPACE         # Do not record an event starting with a space.
setopt HIST_SAVE_NO_DUPS         # Do not write a duplicate event to the history file.
setopt HIST_VERIFY               # Do not execute immediately upon history expansion.
setopt HIST_BEEP                 # Beep when accessing non-existent history.

setopt CORRECT

if ! [[ "${PATH}" =~ "^${HOME}/.cargo/bin" ]]; then
    export PATH="${HOME}/.cargo/bin:${PATH}"
fi

if ! [[ "${PATH}" =~ "^${HOME}/.local/bin" ]]; then
    export PATH="${HOME}/.local/bin:${PATH}"
fi

if ! [[ "${PATH}" =~ "^${HOME}/bin" ]]; then
    export PATH="${HOME}/bin:${PATH}"
fi

#setopt hist_ignore_dups hist_reduce_blanks share_history
#setopt hist_ignore_space no_hist_beep no_beep auto_cd hist_no_store
#setopt cd_able_vars multios

alias ll='ls -l'
#alias ls='ls --color=auto'
alias ls='eza'
alias diff='diff --color=auto'
alias grep='grep --color=auto'
alias ip='ip --color=auto'
alias kill=' kill'
alias tmux='tmux -2'
alias duf='duf -hide-mp /run/credentials/\*'

autoload -Uz colors; colors;
autoload -Uz compinit; compinit;
#autoload -Uz vcs_info

#zstyle ':vcs_info:*' enable git
#zstyle ':vcs_info:git*' formats " %{$fg[yellow]%}(%{$fg[magenta]%}%r %{$fg[yellow]%}%b%B%{$fg[red]%}%u%{$fg[green]%}%c%{$fg[yellow]%}%%b)%{$fg[default]%}"
#zstyle ':vcs_info:git*' actionformats " %{$fg[yellow]%}(%{$fg[magenta]%}%r %{$fg[yellow]%}%b|%a%B%{$fg[red]%}%u%{$fg[green]%}%c%{$fg[yellow]%}%%b)%{$fg[default]%}"
#zstyle ':vcs_info:git*' check-for-changes true
#precmd() { vcs_info }
setopt prompt_subst

[[ "$USER" == "root" ]] && PCOL=$fg[red] || PCOL=$fg[green]
PS1='%{$PCOL%}[%T %B%n%b%{$PCOL%}%\@%m:%B%{$fg[cyan]%}%30<...<%~%b%{$PCOL%}]%#%{$fg[default]%} '
[[ /proc/$PPID/exe -ef /usr/bin/mc ]] || RPS1='${vcs_info_msg_0_}'

zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' menu select

export GPG_TTY=$(tty)

man() {
  env \
    LESS_TERMCAP_mb=$(printf "\e[1;31m") \
    LESS_TERMCAP_md=$(printf "\e[1;31m") \
    LESS_TERMCAP_me=$(printf "\e[0m") \
    LESS_TERMCAP_se=$(printf "\e[0m") \
    LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
    LESS_TERMCAP_ue=$(printf "\e[0m") \
    LESS_TERMCAP_us=$(printf "\e[1;32m") \
    MANROFFOPT=-c \
    man "$@"
}

bindkey '\e[1~' beginning-of-line
bindkey '\e[4~' end-of-line
bindkey '\e[H' beginning-of-line
bindkey '\e[F' end-of-line
bindkey "\e[3~" delete-char
bindkey "\e[1;5C" forward-word
bindkey "\e[1;5D" backward-word
bindkey "${terminfo[khome]}" beginning-of-line
bindkey "${terminfo[kend]}" end-of-line
#bindkey '^R' history-incremental-pattern-search-backward
#bindkey '^F' history-incremental-pattern-search-forward

source <(fzf --zsh)

function dict() {
    /usr/bin/dict $@ | colorit
}
