# Set the directory we want to store zinit and plugins
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"

# Download Zinit, if it's not there yet
if [ ! -d "$ZINIT_HOME" ]; then
   mkdir -p "$(dirname $ZINIT_HOME)"
   git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
fi

# Source/Load zinit
source "${ZINIT_HOME}/zinit.zsh"


# Add in zsh plugins
zinit light zsh-users/zsh-syntax-highlighting
zinit light zsh-users/zsh-completions
zinit light zsh-users/zsh-autosuggestions
zinit light Aloxaf/fzf-tab
zinit light unixorn/fzf-zsh-plugin

# history settings
HISTSIZE=50000
SAVEHIST=10000
HISTFILE=~/.cache/zsh/history
setopt appendhistory
setopt extended_history
setopt hist_expire_dups_first
setopt hist_ignore_all_dups
setopt hist_save_no_dups
setopt hist_ignore_dups
setopt hist_find_no_dups
setopt hist_ignore_space
setopt share_history

# Aliases
alias vim="nvim"
alias vi="nvim"
alias ls="ls --color=auto"
alias k="kubectl"
alias s="systemctl"
alias j="sudo journalctl -u"
alias c="clear"
alias ZZ="exit"
alias less="less -R"

zstyle ':completion:*' menu select
autoload -U colors && colors
autoload -U compinit && compinit

export ANSIBLE_FORCE_COLOR=true
export EDITOR=/usr/bin/nvim

# keybindings
# ctrl-left/right
bindkey "\e[1;5C" forward-word
bindkey "\e[1;5D" backward-word

# ctrl-backspace/delete
bindkey "\C-_" backward-kill-word
bindkey "\e[3;5~" kill-word

# alt-backspace
bindkey "\e\d" undo

bindkey "\e[3~" delete-char
bindkey '\e[H' beginning-of-line
bindkey '\e[F' end-of-line

macchina
eval "$(oh-my-posh init zsh --config /opt/oh-my-posh.json)"
