# Profiling
# https://esham.io/2018/02/zsh-profiling
# See ~/prog/zsh_sort_timings.zsh to sort results
#zmodload zsh/datetime
#setopt PROMPT_SUBST
#PS4='+$EPOCHREALTIME %N:%i> '
#logfile=$(mktemp zsh_profile.XXXXXXXX)
#echo "Logging to $logfile"
#exec 3>&2 2>$logfile
#setopt XTRACE

bindkey -e
export HISTFILE=~/.histfile
HISTSIZE=100000
SAVEHIST=100000

setopt appendhistory
setopt inc_append_history
setopt share_history
setopt extended_history
#setopt print_exit_value
setopt extendedglob
setopt nomatch
setopt interactivecomments

autoload -U compinit
compinit
zstyle ':completion:*:*:cd:*' tag-order local-directories path-directories
zstyle ':completion:*' menu select=2
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*:rm:*' ignore-line yes
zstyle ':completion:*:mv:*' ignore-line yes
zstyle ':completion:*:cp:*' ignore-line yes
zstyle ':completion:::::' completer _expand _complete _ignored _approximate
zstyle ':completion::complete:*' use-cache on               # completion caching, use rehash to clear
zstyle ':completion:*' cache-path ~/.zsh/cache              # cache path
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'   # ignore case

source ~/.zsh/aliases
source ~/.zsh/functions
source ~/.zsh/exports
source ~/.zsh/completion/fzf-completion.zsh

{{- if eq .chezmoi.hostname "taupo" }}
source ~/.zsh/aliases_taupo
source ~/.zsh/functions_taupo
source ~/.config/broot/launcher/bash/br
source /usr/share/virtualenvwrapper/virtualenvwrapper_lazy.sh
#source /usr/share/doc/fzf/examples/key-bindings.zsh
source ~/.zsh/completion/scw-completion.zsh
source ~/.zsh/completion/podman.zsh
{{- end }}

eval "$(zoxide init zsh)"
eval "$(starship init zsh)"
#source <(antibody init)
#antibody bundle < ~/.zsh_plugins
eval "$(sheldon source)"

# Profiling
#unsetopt XTRACE
#exec 2>&3 3>&-

