From a3dfbcefc15901a9c843d0ee4f6ebac4ddcf025a Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Thu, 27 Aug 2026 14:46:18 +0200 Subject: [PATCH] o: strip ANSI escapes on dumb terminals Detect TERM=dumb or non-tty stdout and use plain '> ' prompt instead of bold ANSI escape sequences. --- data/scripts/o | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/data/scripts/o b/data/scripts/o index dbeeb38..e0f33bc 100755 --- a/data/scripts/o +++ b/data/scripts/o @@ -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