# Set up the prompt
# See PS1 below
#autoload -Uz promptinit
#promptinit
#prompt adam1
#prompt adam2 
#prompt fire
#prompt bart
#prompt elite2
#prompt default

# Taken from Kali Linux .zshrc 
# --------- KALI -------------
setopt autocd              # change directory just by typing its name
#setopt correct            # auto correct mistakes
setopt interactivecomments # allow comments in interactive mode
setopt magicequalsubst     # enable filename expansion for arguments of the form ‘anything=expression’
setopt nonomatch           # hide error message if there is no match for the pattern
setopt notify              # report the status of background jobs immediately
setopt numericglobsort     # sort filenames numerically when it makes sense
setopt promptsubst         # enable command substitution in prompt

# configure key keybindings
# Use emacs keybindings even if our EDITOR is set to vi
bindkey -e                                        # emacs key bindings
bindkey ' ' magic-space                           # do history expansion on space
bindkey '^U' backward-kill-line                   # ctrl + U
bindkey '^[[3;5~' kill-word                       # ctrl + Supr
bindkey '^[[3~' delete-char                       # delete
bindkey '^[[1;5C' forward-word                    # ctrl + ->
bindkey '^[[1;5D' backward-word                   # ctrl + <-
bindkey '^[[5~' beginning-of-buffer-or-history    # page up
bindkey '^[[6~' end-of-buffer-or-history          # page down
bindkey '^[[H' beginning-of-line                  # home
bindkey '^[[F' end-of-line                        # end
bindkey '^[[Z' undo                               # shift + tab undo last action

# History configurations
HISTFILE=~/.zsh_history
HISTSIZE=1000
SAVEHIST=2000
setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE
setopt hist_ignore_dups       # ignore duplicated commands history list
setopt hist_ignore_space      # ignore commands that start with space
setopt hist_verify            # show command with history expansion to user before running it
#setopt share_history         # share command history data

# force zsh to show the complete history
alias history="history 0"
# --------- KALI -------------

setopt histignorealldups sharehistory

# Do not ask for confirmation when deleting * or dir/* 
#setopt localoptions rmstarsilent

# Keep 1000 lines of history within the shell and save it to ~/.zsh_history:
HISTSIZE=1000
SAVEHIST=1000
HISTFILE=~/.zsh_history

# Use modern completion system
autoload -Uz compinit
compinit

zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _expand _complete _correct _approximate
zstyle ':completion:*' format 'Completing %d'
zstyle ':completion:*' group-name ''
eval "$(dircolors -b)"
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
zstyle ':completion:*' menu select=long
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose true

zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'

zstyle ':completion:*' menu select=0
#zstyle ':completion:*' menu select=2


# ---------------------------------------
# zplug - manage plugins
source /usr/share/zplug/init.zsh
#zplug "junegunn/fzf"
#zplug "plugins/git", from:oh-my-zsh
#zplug "plugins/debian", from:oh-my-zsh
zplug "zsh-users/zsh-syntax-highlighting"
zplug "zsh-users/zsh-autosuggestions"
zplug "zsh-users/zsh-history-substring-search"
zplug "zsh-users/zsh-completions"
zplug "plugins/sudo", from:oh-my-zsh
zplug "plugins/command-not-found", from:oh-my-zsh
#zplug "plugins/extract", from:oh-my-zsh
#zplug "plugins/rsync", from:oh-my-zsh
#zplug "plugins/screen", from:oh-my-zsh

# zplug - install/load new plugins when zsh is started or reloaded
if ! zplug check --verbose; then
    printf "Install? [y/N]: "
    if read -q; then
        echo; zplug install
    fi
fi
#zplug load --verbose
zplug load 

# ---------------------------------------
# My own stuff 
alias ls='ls --color=auto'
alias l='ls -lh'
alias ll='ls -lha'
alias df='df -h'
alias free='free -mt'
alias top='htop'
alias vi='vim'
alias ip='ip --color=auto'
alias diff='diff --color=auto'
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias saveKDESession='qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.saveCurrentSession'

# Key bindings
bindkey '^H' backward-kill-word

# Make Esc+Backspace work as in Bash ;)
# These chars will be erased together with words.
#export WORDCHARS='*?_-.[]~=&;!#$%^(){}<>'
export WORDCHARS='*?_-[]~=&;!#$%^(){}<>'

# Hide the EOL char ('%') at the end of lines
PROMPT_EOL_MARK=""

# ----------
# IMPORTANT!
# ----------
# Do not use " with your PS1 or things like vcs_info will NOT work! 
# Prefer using ' for the PS1 varialbe. See example below.
# Last checked on: Mon 12 Dec 2022 10:03:41 PM EST

# Version control (GIT)
# Enable VCS (GIT,SVN) support
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git svn
precmd() {
    vcs_info
}

setopt prompt_subst
zstyle ':vcs_info:git*' formats '%F{magenta}%s<%f%F{yellow}%b%f%F{magenta}>[%f%F{yellow}%a %m%u%c%f%F{magenta}]%f'
# This may slow things a bit
#zstyle ':vcs_info:*' check-for-changes true  

clear
unset PS1
# This will make a fancy prompt with stats about your session.
#NEWLINE=$'\n'
#TOPBAR="----------------------------------------------------------------"
#MIDBAR="| Line:%y | Jobs:%j | SHLVL:%L | Return:%? | %D{%d %b %Y} %T |"
#BOTBAR="----------------------------------------------------------------"
#PS1STR="${TOPBAR}${NEWLINE}${MIDBAR}${NEWLINE}${BOTBAR}${NEWLINE}"
#PS1='${PS1STR}%B%F{yellow}[%f%F{green}%n%f%F{yellow}@%f%F{blue}%m%f ${vcs_info_msg_0_} %F{white}%~%f%F{yellow}]%f %F{red}%(!.#.$)%f%b '

# This is justa fancy promptp without stats. Just VCS integration and FULL path
#PS1='%B%F{yellow}[%f%F{green}%n%f%F{yellow}@%f%F{blue}%m%f ${vcs_info_msg_0_} %F{white}%~%f%F{yellow}]%f %F{red}%(!.#.$)%f%b '

# This is justa fancy promptp without stats. Just VCS integration and RELATIVE path
PS1='%B%F{yellow}[%f%F{green}%n%f%F{yellow}@%f%F{blue}%m%f ${vcs_info_msg_0_} %F{white}%1~%f%F{yellow}]%f %F{red}%(!.#.$)%f%b '

export PS1

# Include user's bin directory
if [ -d ~/bin ]; then
    export PATH=$PATH:~/bin
fi



