# My special: START
if command -v fastfetch >/dev/null 2>&1; then
  fastfetch
elif command -v neofetch >/dev/null 2>&1; then
  neofetch
fi
# My special: END


# 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

export ZSH="$HOME/.oh-my-zsh"

ZSH_THEME="powerlevel10k/powerlevel10k"

plugins=(git)

source "$ZSH/oh-my-zsh.sh"

[[ -f "$HOME/.p10k.zsh" ]] && source "$HOME/.p10k.zsh"

# Dynamic terminal background colors for normal, root-like and Copilot sessions.
autoload -Uz add-zsh-hook

typeset -g P10K_TERM_BG_NORMAL='#171421'
typeset -g P10K_TERM_BG_ROOT='#2a161b'
typeset -g P10K_TERM_BG_COPILOT='#182033'

p10k_term_set_bg() {
  [[ -t 1 ]] || return
  printf '\e]11;%s\a' "$1"
}

p10k_term_apply_prompt_bg() {
  if [[ $EUID -eq 0 ]]; then
    p10k_term_set_bg "$P10K_TERM_BG_ROOT"
  else
    p10k_term_set_bg "$P10K_TERM_BG_NORMAL"
  fi
}

p10k_term_apply_command_bg() {
  local cmd="${1:l}"

  case "$cmd" in
    copilot*|gh\ copilot*|gh\ cs*|github-copilot*|*copilot\ *)
      p10k_term_set_bg "$P10K_TERM_BG_COPILOT"
      ;;
    sudo\ -i*|sudo\ -s*|sudo\ su*|su\ -|su\ -\ root*|su\ root*)
      p10k_term_set_bg "$P10K_TERM_BG_ROOT"
      ;;
    *)
      p10k_term_apply_prompt_bg
      ;;
  esac
}

term-bg-normal() { p10k_term_set_bg "$P10K_TERM_BG_NORMAL"; }
term-bg-root() { p10k_term_set_bg "$P10K_TERM_BG_ROOT"; }
term-bg-copilot() { p10k_term_set_bg "$P10K_TERM_BG_COPILOT"; }

add-zsh-hook precmd p10k_term_apply_prompt_bg
add-zsh-hook preexec p10k_term_apply_command_bg

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
alias ls='eza --icons=always --group-directories-first --group'

# GitHub Copilot CLI helpers
alias c='copilot'

# Jarvis (local AI) helpers
JARVIS_DIR="$HOME/Misc/Development/OpenJarvis"
alias jarvis='cd "$JARVIS_DIR" && uv run jarvis'

j() {
    (cd "$JARVIS_DIR" && uv run jarvis ask "$*")
}

jchat() {
    (cd "$JARVIS_DIR" && uv run jarvis chat)
}

ghcs() {
    copilot "Suggest a shell command for: $*"
}

ghce() {
    copilot "Explain this shell command: $*"
}

cpcmd() {
    copilot "Suggest a shell command for: $*"
}

cpexplain() {
    copilot "Explain this shell command: $*"
}
if [[ -f "$HOME/.cargo/env" ]]; then
  . "$HOME/.cargo/env"
  export PATH="$HOME/.cargo/bin:$PATH"
fi





# Editor should be mg!!!
export EDITOR=mg
export VISUAL=mg
