# /etc/zsh/zprofile — managed by ckn-bw bundles/zsh
# Sourced for login shells only. SSH gives login shells; that's all we need.

setopt prompt_subst
autoload -Uz colors && colors
autoload -Uz compinit && compinit

zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'

# Mirrors the old bw.zsh-theme colors (sans git segment) plus a closing arrow:
#   user  — bold, yellow normally, green as root
#   host  — bold, green when last cmd succeeded, red otherwise
#   path  — cyan (full path, ~ for $HOME)
#   ❯     — bold, same green/red as host
PROMPT='%B%(!.%F{green}.%F{yellow})%n%f%b@%B%(?.%F{green}.%F{red})%m%f%b %F{cyan}%~%f %(?.%F{green}.%F{red})%B❯%b%f '

# Prefix-based history search on arrow keys
autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey '^[[A' up-line-or-beginning-search
bindkey '^[[B' down-line-or-beginning-search
bindkey '^[OA' up-line-or-beginning-search
bindkey '^[OB' down-line-or-beginning-search

# Autosuggestions (apt-installed; guarded for minimal images)
[[ -r /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh ]] \
  && source /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh

# Server-only conveniences, carried over from the old zprofile
alias s='sudo su - root -s /usr/bin/zsh'
hhtop() {
  mkdir -p ~/.config/htop
  cp /etc/htoprc.global ~/.config/htop/htoprc
  htop
}
