# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
bindkey -e

# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
zstyle :compinstall filename '/home/ward/.zshrc'

autoload -Uz compinit
compinit
# End of lines added by compinstall

# Fixing some keys inside zsh
bindkey "^[[H" beginning-of-line #Home-key
bindkey "^[[F" end-of-line #End-key
bindkey "^[[3~" delete-char #Delete-key

# personal aliases
alias ls='ls --color=auto'
alias la='ls -a'
alias ll='ls -lh'
alias cp='cp -v'
alias mv='mv -v'
alias rm='rm -v'
alias ..='cd ..'

# Java home
export JAVA_HOME=/usr/lib/jvm/default

# Plugin idea copy from https://github.com/KulkarniKaustubh/dotfiles/blob/main/zsh/.plugins.zsh
# check if ~/.zsh exists
if [ ! -d "$HOME/.zsh" ]; then
    echo "Creating a .zsh folder in $HOME"
    echo "This can be copied elsewhere and then linked, preferrably using GNU stow"
    mkdir $HOME/.zsh
fi

# check if p10k exists
if [ ! -d "$HOME/.zsh/powerlevel10k" ]; then
    echo "Installing powerelevel10k theme."
    git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $HOME/.zsh/powerlevel10k
fi
source $HOME/.zsh/powerlevel10k/powerlevel10k.zsh-theme

# check if zsh autosuggest exists
if [ ! -d "$HOME/.zsh/zsh-autosuggestions" ]; then
    echo "Installing zsh autosuggestions."
    git clone https://github.com/zsh-users/zsh-autosuggestions $HOME/.zsh/zsh-autosuggestions
fi
source $HOME/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
