From bcdd58f4b314ac02470e3bb2be0df8aa8ba0142c Mon Sep 17 00:00:00 2001 From: Brett Kinny Date: Wed, 5 Aug 2026 21:24:16 +1000 Subject: [PATCH] Suppress MOTD in Herdr panes --- motd.sh | 5 +++++ tests/test-motd-startup-policy.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100755 tests/test-motd-startup-policy.sh diff --git a/motd.sh b/motd.sh index cf254d1..72d9296 100644 --- a/motd.sh +++ b/motd.sh @@ -1,6 +1,11 @@ #!/bin/bash # squarebox MOTD — orange metallic banner with SDK info +# Herdr creates a fresh interactive shell for every managed pane and exports +# HERDR_ENV=1 there. The outer Box shell has already shown the MOTD, so avoid +# repeating the full banner in every Herdr tab and split. +[ "${HERDR_ENV:-}" = 1 ] && exit 0 + # Orange metallic: bright orange heading, muted orange date printf '\e[1;38;5;208m' toilet -f smblock --metal "squarebox" diff --git a/tests/test-motd-startup-policy.sh b/tests/test-motd-startup-policy.sh new file mode 100755 index 0000000..d993e50 --- /dev/null +++ b/tests/test-motd-startup-policy.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) +TMP=$(mktemp -d) +trap 'rm -rf "$TMP"' EXIT + +mkdir -p "$TMP/bin" +cat > "$TMP/bin/toilet" <<'EOF' +#!/usr/bin/env bash +printf 'squarebox\n' +EOF +chmod +x "$TMP/bin/toilet" + +normal_output=$(HERDR_ENV=0 PATH="$TMP/bin:$PATH" bash "$ROOT/motd.sh") +if [[ "$normal_output" != *squarebox* ]]; then + echo "FAIL: MOTD should render outside Herdr" >&2 + exit 1 +fi + +herdr_output=$(HERDR_ENV=1 PATH="$TMP/bin:$PATH" bash "$ROOT/motd.sh") +if [ -n "$herdr_output" ]; then + echo "FAIL: MOTD should be silent in a Herdr-managed pane" >&2 + exit 1 +fi + +echo "PASS: MOTD renders normally and stays silent inside Herdr"