From 9bb93025f0e71e6e4e8e1b296b7d00f426861a59 Mon Sep 17 00:00:00 2001 From: Joakim Persson Date: Tue, 21 Apr 2026 23:52:03 +0200 Subject: [PATCH] Fix [devbox] prompt marker disappearing after 'exec bash' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous guard used an exported DEVBOX_PS1_SET env var to avoid double-prefixing on re-source. But env vars survive 'exec bash' while PS1 does not — a new bash rebuilds PS1 from .bashrc. Result: the guard saw DEVBOX_PS1_SET=1, skipped the prefix, and the new shell ran with bare PS1 (no [devbox] marker). Replace the env-var guard with a substring check on PS1 itself. If PS1 already contains '[devbox]' we skip, otherwise we prepend. Correct in all three cases: first shell (PS1 has no marker → add), exec bash (fresh PS1 has no marker → add), re-source within same shell (PS1 still has marker → skip, no doubling). --- rootfs/home/developer/.bash_aliases | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rootfs/home/developer/.bash_aliases b/rootfs/home/developer/.bash_aliases index 0a6da46..ca9e902 100644 --- a/rootfs/home/developer/.bash_aliases +++ b/rootfs/home/developer/.bash_aliases @@ -76,7 +76,10 @@ fi # ── Prompt: show [opencode-devbox] tag so it's obvious you're in the container # Preserves the default Debian PS1 logic but prefixes with a container marker. -if [ -n "${PS1:-}" ] && [ -z "${DEVBOX_PS1_SET:-}" ]; then +# We check for the literal '[devbox]' substring in PS1 rather than relying on +# an exported guard variable — otherwise `exec bash` inherits the guard but +# gets a fresh (prefix-less) PS1 from .bashrc, and the prefix would never be +# re-added in the new shell. +if [ -n "${PS1:-}" ] && [[ "$PS1" != *"[devbox]"* ]]; then PS1='\[\e[38;5;39m\][devbox]\[\e[0m\] '"${PS1}" - export DEVBOX_PS1_SET=1 fi