# blake's zsh config file
# 'source .zshrc' to load the config after editing

# prompt
#PS1='%B%S%F{004}[%n@%m]:%f%s%F{015}%~%f%S%F{004}$%f%s%b '

# blakes prompt
PS1='%F{0}%K{126}%B[%n@%m]%b%k%f:%F{015}%B[%~]%b%f%F{015}%S$%s%f '

# --- defaults ---
export EDITOR=nvim
export PAGER=less

# --- history ---
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=~/.config/zsh/.zsh_history
setopt append_history
setopt inc_append_history
unsetopt share_history 

# --- tab complete ---
autoload -Uz compinit && compinit
setopt no_menu_complete
compinit

# --- aliases ---

# zsh
alias cfz='nvim $HOME/.config/zsh/.zshrc'
alias src='source $HOME/.config/zsh/.zshrc'

# config editing
alias cfh='nvim $HOME/.config/hypr/hyprland.conf'

# navigation
setopt autocd
set -o vi
alias ls='ls --color=auto --group-directories-first'
alias ll='ls -lh --color=auto --group-directories-first'
alias la='ls -Alh --color=auto --group-directories-first'
alias ..='cd ..'
alias ...='cd ../..'
alias fs='du -h | sort -h'
alias ds='du -hs'

# shortcuts
alias vswap='cd ~/.local/state/nvim/swap'
alias tn='lf ~/documents/holocron/notes/tech'
alias nhc='lf ~/documents/holocron/work/nhc'
alias diary='cd ~/documents/holocron/notes/journal/diary'
alias screenies='lf ~/pictures/screenshots'
alias holo='lf ~/documents/holocron'

# safety
alias cp='cp -iv'
alias mv='mv -iv'
alias rm='rm -Iv'

# colors
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'

# packages
alias rebuild='sh ~/.nix/rebuild.sh'

# tools
alias v='nvim'
alias sv='sudo nvim'
alias vim='nvim'
alias wifi='nmtui'
alias bt='bluetuith --no-warning'
alias audio='pulsemixer'
alias img='nsxiv'
alias vid='mpv'
alias pdf='zathura'
alias fw='sudo ufw status verbose'

# git
alias status='git status'
alias add='git add'
alias commit='git commit -am'
alias push='git push'
alias pull='git pull'
alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles --work-tree=$HOME'
alias dtf='/usr/bin/git --git-dir=$HOME/.dotfiles --work-tree=$HOME'

# shortcuts
alias chil='nvim ~/documents/holocron/tech/devices/yveltal/chilton'
alias school='nvim ~/documents/holocron/school/school.md'

# system
alias peace='systemctl poweroff'
alias love='systemctl reboot'
alias lock='loginctl lock-session'

# ssh
alias nebby='ssh nebula'

# wild shit
alias mgdrive='rclone mount gdrive: /media/gdrive --daemon --vfs-cache-mode writes'
alias micloud='rclone mount icloud: /media/icloud --daemon --vfs-cache-mode writes'
alias smp='mcrcon -H 10.0.0.104 -P 25575 -p WoopaGangaRecProGamingPassLmaoJkJk'
alias mcap='sudo umount /media/microsd ; sudo cryptsetup luksClose /dev/mapper/capsule ; sudo cryptsetup luksOpen UUID=a9e81f14-1e74-4777-a37a-81a0a43ae8d9 capsule --key-file ~/.config/cred/capsule.keyfile ; sudo mount -a'

# --- ssh auth sock ---
export GPG_TTY=$(tty)
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpgconf --launch gpg-agent

# --- path ---

# Define directories to add to PATH
ADDTOPATHS=(
    "$HOME/.local/bin"
    "$HOME/.local/bin/timecapsule"
)

for ADDTOPATH in "${ADDTOPATHS[@]}"; do
    if [ -d "$ADDTOPATH" ]; then
        case ":${PATH}:" in
            *:"${ADDTOPATH}":*) 
                ;;
            *) 
                PATH="${PATH}:${ADDTOPATH}"
                ;;
        esac
    else
    fi
done
export PATH

# --- scripts ---
# make lf change the working directory upon exit
alias lf='lfcd'
lfcd () {cd "$(command lf -print-last-dir "$@")"}

# --- plugins ---
# you really hate the idea of your zshrc auto cloning 
# and installling the plugin manager. To do so manually:
# git clone https://github.com/zplug/zplug "$HOME/.config/zsh/zplug"

export ZPLUG_HOME="$HOME/.config/zsh/zplug/"  # Change this to your custom directory
if [ -d "$HOME/.config/zsh/zplug" ]; then
    export ZPLUG_INSTALLED="1"
    source "$HOME/.config/zsh/zplug/init.zsh"
else
    if [[ $- == *i* ]]; then
        echo "⚠️  zplug is not installed. Run: git clone https://github.com/zplug/zplug $HOME/.config/zsh/zplug"
    fi
fi

# init zplug
if [ -n "ZPLUG_INSTALLED" ]; then
    zplug "zsh-users/zsh-syntax-highlighting", defer:2
    zplug "zsh-users/zsh-history-substring-search"
    zplug "zsh-users/zsh-autosuggestions"  # Command suggestions as you type
    zplug "zsh-users/zsh-completions"      # Additional completions for more commands
    zplug "olivierverdier/zsh-git-prompt"
    zplug load
    # install if there are new plugins 
    if ! zplug check --verbose; then
        zplug install
        zplug load
    fi
fi

# -- syntax highlighting --
# Adjusted zsh-syntax-highlighting colors for red-green color blindness
ZSH_HIGHLIGHT_STYLES[default]=none
ZSH_HIGHLIGHT_STYLES[unknown-token]=fg=magenta  # (Was red)
ZSH_HIGHLIGHT_STYLES[reserved-word]=fg=cyan
ZSH_HIGHLIGHT_STYLES[alias]=fg=blue  # (Was green)
ZSH_HIGHLIGHT_STYLES[builtin]=fg=cyan
ZSH_HIGHLIGHT_STYLES[function]=fg=blue  # (Was green)
ZSH_HIGHLIGHT_STYLES[command]=fg=blue,bold  # (Was green)
ZSH_HIGHLIGHT_STYLES[precommand]=fg=cyan
ZSH_HIGHLIGHT_STYLES[commandseparator]=fg=cyan
ZSH_HIGHLIGHT_STYLES[hashed-command]=fg=blue  # (Was green)
ZSH_HIGHLIGHT_STYLES[path]=fg=cyan,underline  # This ensures paths are underlined
ZSH_HIGHLIGHT_STYLES[globbing]=fg=cyan
ZSH_HIGHLIGHT_STYLES[history-expansion]=fg=magenta  # (Was red)
ZSH_HIGHLIGHT_STYLES[single-hyphen-option]=fg=cyan
ZSH_HIGHLIGHT_STYLES[double-hyphen-option]=fg=cyan
ZSH_HIGHLIGHT_STYLES[back-quoted-argument]=fg=cyan
ZSH_HIGHLIGHT_STYLES[single-quoted-argument]=fg=white,bold
ZSH_HIGHLIGHT_STYLES[double-quoted-argument]=fg=white
ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]=fg=cyan
ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]=fg=cyan
ZSH_HIGHLIGHT_STYLES[assign]=fg=cyan
ZSH_HIGHLIGHT_STYLES[comment]=fg=yellow

