o: strip ANSI escapes on dumb terminals

Detect TERM=dumb or non-tty stdout and use plain '> ' prompt
instead of bold ANSI escape sequences.
This commit is contained in:
Levi Neely 2026-08-27 14:46:18 +02:00
parent 765e8b9d05
commit a3dfbcefc1
1 changed files with 11 additions and 1 deletions

View File

@ -29,6 +29,12 @@
set -euo pipefail
# ── Terminal capability ──────────────────────────────────────────
USE_COLOR=true
if [[ "${TERM:-dumb}" == "dumb" ]] || [[ ! -t 1 ]]; then
USE_COLOR=false
fi
# ── Globals set by dispatch ─────────────────────────────────────
PREFIX="" # Path prefix based on context
CTX_SESSION="" # Session name if in session/agent context
@ -194,7 +200,11 @@ cmd_prompt() {
while true; do
local prompt_str
if [[ -z "$buf" ]]; then
prompt_str=$'\033[1m>\033[0m '
if $USE_COLOR; then
prompt_str=$'\033[1m>\033[0m '
else
prompt_str='> '
fi
else
prompt_str=" "
fi