# spacesh zsh OSC 133 integration. Sourced from a per-surface ZDOTDIR .zshrc
# after the user's ~/.zshrc. Emits semantic-prompt markers so the daemon can
# detect command start/end and exit status.
autoload -Uz add-zsh-hook 2>/dev/null

_spacesh_precmd() {
  local code=$?
  # End previous command (D) with its exit code, then mark prompt start (A).
  print -n "\e]133;D;${code}\a\e]133;A\a"
}
_spacesh_preexec() {
  # Command output begins (C).
  print -n "\e]133;C\a"
}
add-zsh-hook precmd _spacesh_precmd 2>/dev/null
add-zsh-hook preexec _spacesh_preexec 2>/dev/null
