# Managed by Bill/phone-setup (symlinked to ~/.zshrc by termux/bootstrap.sh).
# Mirrors the soos Home-Manager zsh, minus nix-store paths and secrets.

# Powerlevel10k instant prompt
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

autoload -U compinit && compinit

ZPLUG=~/.zsh/plugins
source $ZPLUG/powerlevel10k/powerlevel10k.zsh-theme
source $ZPLUG/zsh-autosuggestions/zsh-autosuggestions.zsh
ZSH_AUTOSUGGEST_STRATEGY=(history)

HISTSIZE=10000
SAVEHIST=10000
HISTFILE=~/.zsh_history
setopt HIST_FCNTL_LOCK HIST_IGNORE_DUPS HIST_IGNORE_SPACE SHARE_HISTORY

[[ -f ~/.p10k.zsh ]] && source ~/.p10k.zsh

# Termux: the prebuilt gitstatusd is a static musl binary, and Termux's
# system-linker-exec (default since 0.119 / required by Android W^X) cannot
# exec static binaries -> "gitstatus failed to initialize". Fall back to
# vcs_info. MUST come after ~/.p10k.zsh, whose preamble unsets POWERLEVEL9K_*.
# For a fast prompt instead, compile on-device:
#   pkg install clang binutils make cmake && $ZPLUG/powerlevel10k/gitstatus/build -w -s
[[ $OSTYPE == linux-android ]] && POWERLEVEL9K_DISABLE_GITSTATUS=true

alias eza='eza --icons auto --git'
alias ls=eza
alias la='eza -a'
alias ll='eza -l'
alias lla='eza -la'
alias lt='eza --tree'
alias yolo='claude --dangerously-skip-permissions'

lg() {
  export LAZYGIT_NEW_DIR_FILE=~/.lazygit/newdir
  command lazygit "$@"
  if [ -f "$LAZYGIT_NEW_DIR_FILE" ]; then
    cd "$(cat "$LAZYGIT_NEW_DIR_FILE")"
    rm -f "$LAZYGIT_NEW_DIR_FILE" >/dev/null
  fi
}

# Syntax highlighting MUST be sourced last
source $ZPLUG/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
