Keep .bashrc a bootstrap, and secrets out of the checkout for real

.bashrc is back to its one job: export the Panama paths and source
what it finds. The personal-env block moves into config/bash/shell —
first, because the tmux guard below it reads that file — and the
cargo source that was duplicated between the two files lives only in
shell now.

The real fix is behind that tidying: both Home Assistant helpers
defaulted to the IN-REPO config/bash/env, and the writer rebuilt it
with only its own three lines — which read as "my env vars vanished"
to the person who thought that file was hand-maintained. Both now
prefer ~/.config/panama/env, the migrated home outside the checkout,
with the repo path kept only as a read fallback for unmigrated
machines. The stale legacy copy on this machine is retired; the
working credentials were merged into the migrated file first, after
probing both sets against the live Home Assistant.

Claude-Session: https://claude.ai/code/session_01Ms2FbjQy31TVf3CEvQhGM8
This commit is contained in:
Gabriel Brown
2026-08-24 08:49:40 -04:00
parent f8f5b25510
commit 1f694b00b6
4 changed files with 46 additions and 27 deletions
@@ -29,7 +29,20 @@ ASSIGNMENT = re.compile(
r"^(?P<prefix>\s*(?:export\s+)?)(?P<key>[A-Za-z_][A-Za-z0-9_]*)\s*=(?P<value>.*)$"
)
ENTITY_ID = re.compile(r"^[a-z_]+\.[a-z0-9_]+$")
DEFAULT_ENV = pathlib.Path(__file__).resolve().parents[3] / "bash/env"
# Personal environment lives OUTSIDE the checkout (~/.config/panama/env),
# where agents, backup tools and `panama update` never walk. The in-repo
# config/bash/env is only the legacy location for unmigrated machines — and
# writing there once rebuilt a file the owner thought was hand-maintained.
LEGACY_ENV = pathlib.Path(__file__).resolve().parents[3] / "bash/env"
def default_env() -> pathlib.Path:
config_home = pathlib.Path(
os.environ.get("XDG_CONFIG_HOME", str(pathlib.Path.home() / ".config")))
migrated = config_home / "panama" / "env"
if migrated.exists() or not LEGACY_ENV.exists():
return migrated
return LEGACY_ENV
class ConfigError(RuntimeError):
@@ -38,7 +51,7 @@ class ConfigError(RuntimeError):
def env_path() -> pathlib.Path:
override = os.environ.get("PANAMA_HOME_ASSISTANT_ENV_FILE", "")
return pathlib.Path(override) if override else DEFAULT_ENV
return pathlib.Path(override) if override else default_env()
def parse_assignment(raw: str) -> str | None: