# ─── Ensure Ruby Gem Binaries Are in PATH ──────────────────────────────
setopt nullglob
for dir in "$HOME/.gem/ruby/"*/bin ; do
  [[ -d $dir ]] && PATH="$PATH:$dir"
done
export PATH

# ─── Powerlevel10k Instant Prompt (Should stay close to the top) ───────
typeset -g POWERLEVEL9K_INSTANT_PROMPT=off
autoload -Uz compinit
compinit

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

# ─── Oh My Zsh and Theme Setup ────────────────────────────────────────
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="powerlevel10k/powerlevel10k"
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

# ─── Plugins ──────────────────────────────────────────────────────────
plugins=(git zsh-autosuggestions zsh-syntax-highlighting zsh-completions)

# ─── Autosuggestions ──────────────────────────────────────────────────
# fg=244 ensures the suggestion hint is visible on both dark and light themes
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=244'

source $ZSH/oh-my-zsh.sh

# ─── Aliases: Use colorls If Available, Fallback to ls ────────────────
if command -v colorls >/dev/null 2>&1; then
  alias ls='colorls -d'
  alias ll='colorls -l'
  alias la='colorls -a'
  alias sls='colorls'
else
  alias ls='ls --color=auto'
  alias ll='ls -l --color=auto'
  alias la='ls -a --color=auto'
  alias sls='ls'
fi

# ─── User Aliases and Functions ───────────────────────────────────────
alias up="/home/$USER/ZSHkit/up.sh --update-only"    # quick updates only
alias upc="/home/$USER/ZSHkit/up.sh --config"        # first-run: install & suppress tools
alias uph="/home/$USER/ZSHkit/up.sh --health"        # health check only
alias ups="/home/$USER/ZSHkit/up.sh --suggest"       # suggestions & info mode only
alias uphelp="/home/$USER/ZSHkit/up.sh --help"       # show all up commands
alias zup="/home/$USER/ZSHkit/update_zshrc.sh"       # merge new ZSHkit sections into local ~/.zshrc
alias p10="p10k configure"
alias fresh='source ~/.zshrc'
alias clear='clear && source ~/.zshrc'
alias nano='TERM=xterm nano'
alias ali='grep "^alias" ~/.zshrc'
alias rsy='rsync -ah --info=progress2 --no-inc-recursive'

# ─── Welcome Message and HomeDir Listing ──────────────────────────────
echo ""
fastfetch
echo ""
sls

# ─── Optional: Additional User Configuration ──────────────────────────
# export LANG=en_US.UTF-8
# export EDITOR='nvim'
# export MANPATH="/usr/local/man:$MANPATH"
# HIST_STAMPS="mm/dd/yyyy"

# End of .zshrc
export EDITOR="nano"
export VISUAL="nano"
