automated_script: restore proven gum stream/env contract

Restore the env + redirect setup that the previously-working ISO
installer used (matching /home/ryan/Downloads/ISO scripts/.automated_script.sh):

  export COLUMNS=$(tput cols)
  export LINES=$(tput lines)
  exec > >(tee >(sed CSI-strip >> log) 2>/dev/null) 2>/dev/tty
  export CLICOLOR_FORCE=1
  export FORCE_COLOR=1

The cutover commit (064b5e2) silently dropped these. Subsequent
attempts to fix the TTY/gum rendering by reshaping the redirect were
all symptom-chasing — the proven shape was correct. The key insight:

  - gum draws its TUI on stderr, not stdout. 2>/dev/tty keeps that
    rendering on the real terminal.
  - stdout-as-pipe (via tee) is *desired*: it lets gum detect a
    non-TTY stdout and skip cursor-position probes (CSI 6n). Without
    that detection, the DSR replies leak as visible ^[[13;1R bytes.
  - CLICOLOR_FORCE/FORCE_COLOR force gum to still emit colour despite
    stdout being a pipe.

Also drops the configurator's _drain_tty workaround — unnecessary
once gum stops sending DSR queries in the first place.
This commit is contained in:
Ryan Hughes committed 2026-05-21 20:54:05 -04:00
1 parent 8734136908
commit 16cc1058be
2 files changed
+13 -32

No files matched your search

+13 -21
View File
@@ -1,8 +1,13 @@
#!/usr/bin/env bash
#
# Live ISO entry point on tty1: set up the live VT, run the configurator
# wizard with full TTY access, then start broad logging and hand off to the
# Python install orchestrator.
# wizard, then hand off to the Python install orchestrator. Mirrors the
# stream/env contract from the previously-working installer:
# - stdout teed to /var/log/omarchy-install.log (CSI-stripped) AND to tty
# - stderr direct to /dev/tty so gum (which draws its TUI on stderr)
# renders correctly
# - CLICOLOR_FORCE/FORCE_COLOR so gum emits ANSI even with stdout piped
# - COLUMNS/LINES so gum picks up real terminal size
set -euo pipefail
[[ $(tty) == /dev/tty1 ]] || exit 0
@@ -26,30 +31,17 @@ set_tokyo_night_colors() {
}
set_tokyo_night_colors
# Tell gum and friends the actual terminal size. stty size on /dev/tty is
# more reliable than tput when stdout could end up redirected.
if size=$(stty size </dev/tty 2>/dev/null); then
export LINES="${size%% *}"
export COLUMNS="${size##* }"
fi
# Configurator phase: real TTY on both streams. No tee/pipe.
mkdir -p /var/log
touch "$OMARCHY_INSTALL_LOG_FILE"
# Drain any stale terminal input (e.g., cursor-position-report responses left
# in the kernel tty input buffer by archiso's boot init). `read -t 0` only
# tests for input; we need a small positive timeout so the read actually
# consumes bytes and then returns.
read -r -t 0.05 -N 9999 _drain </dev/tty 2>/dev/null || true
export COLUMNS=$(tput cols)
export LINES=$(tput lines)
exec > >(tee >(sed -u 's/\x1b\[[0-9;]*[a-zA-Z]//g' >>"$OMARCHY_INSTALL_LOG_FILE") 2>/dev/null) 2>/dev/tty
export CLICOLOR_FORCE=1
export FORCE_COLOR=1
cd /root
./configurator >/dev/tty 2>/dev/tty
# Install phase: now safe to capture output to the install log. Strip CSI
# escapes so the log file is readable. Keep stderr going to the log too so
# install-time errors are captured.
exec > >(tee >(sed -u 's/\x1b\[[0-9;]*[a-zA-Z]//g' >>"$OMARCHY_INSTALL_LOG_FILE") >/dev/tty) 2>&1
./configurator
# Absolute paths because omarchy-iso-install cd's into /usr/share/omarchy-iso
# before exec'ing python; relative paths would resolve against the wrong dir.
-11
View File
@@ -13,21 +13,10 @@ abort() {
exit 1
}
# Drain any pending terminal-reply bytes (cursor position reports, etc.)
# that gum's TUI startup sends but doesn't always consume. Without this,
# bytes like ^[[13;1R show up next to step titles.
_drain_tty() {
# Consume up to 9999 bytes of pending tty input with a short timeout.
# `read -t 0` only TESTS for input; it doesn't consume — that pattern
# hangs forever the moment any data is actually pending.
read -r -t 0.05 -N 9999 _drain </dev/tty 2>/dev/null || true
}
step() {
clear_logo
echo
gum style "$1"
_drain_tty
echo
}