From 07a3e32431932af95f6367cfa408b7544f6c5ddc Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Thu, 16 Jul 2026 00:15:44 -0700 Subject: [PATCH 1/2] Redirect zsh HISTFILE out of the signed app bundle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit macOS /etc/zshrc runs while ZDOTDIR still points at the bundled shell-integration directory and sets HISTFILE inside it. On shell exit zsh then writes .zsh_history into the signed app bundle, breaking its code signature — the next launch fails Gatekeeper with "Dormouse Terminal.app is damaged and can't be opened". Our .zshrc now redirects a HISTFILE that points into our directory back to the user's ZDOTDIR, after sourcing the user's rc so a HISTFILE they set themselves is never touched. Co-Authored-By: Claude Fable 5 --- docs/specs/terminal-escapes.md | 2 +- .../sidecar/shell-integration/zsh/.zshrc | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/docs/specs/terminal-escapes.md b/docs/specs/terminal-escapes.md index e79de847..7a62a30f 100644 --- a/docs/specs/terminal-escapes.md +++ b/docs/specs/terminal-escapes.md @@ -148,7 +148,7 @@ A binary on `PATH` only has to be **found**, so it injects via one env var (`DOR | Shell | Mechanism | Channel | Notes | |---|---|---|---| -| zsh | `ZDOTDIR` → our dotfiles chain to the user's, then install `precmd`/`preexec` hooks | env (as reliable as the `PATH` prepend) | User's real `ZDOTDIR` is passed through as `USER_ZDOTDIR`; our `.zshrc` hands `ZDOTDIR` back so `.zlogin` and child shells are unaffected. | +| zsh | `ZDOTDIR` → our dotfiles chain to the user's, then install `precmd`/`preexec` hooks | env (as reliable as the `PATH` prepend) | User's real `ZDOTDIR` is passed through as `USER_ZDOTDIR`; our `.zshrc` hands `ZDOTDIR` back so `.zlogin` and child shells are unaffected. **Nothing may be written into our directory when shipped** — it sits inside the signed macOS app bundle, and any added file breaks the code signature (Gatekeeper then reports the app "damaged"). macOS `/etc/zshrc` runs while `ZDOTDIR` still points at our directory and sets `HISTFILE` inside it; our `.zshrc` redirects such a `HISTFILE` to `USER_ZDOTDIR` after sourcing the user's rc (a user-set `HISTFILE` is never touched). | | bash | `--init-file` → our script replicates login-profile sourcing, then installs a `DEBUG`-trap / `PROMPT_COMMAND` hook | shellArgs | `--init-file` and login mode are mutually exclusive, so Dormouse drops `-l` and the script sources `/etc/profile` + the user's profile itself. Injected whenever the launch args are *only* interactive/login flags (`-i`/`-l`/`--login`) — so Git Bash, launched with `--login -i`, is covered too; a specific invocation like `-c ` is left untouched. Written for bash 3.2 (macOS system bash): no `PS0`, no array `PROMPT_COMMAND`. The `E` command line is the first simple command of a pipeline (a `DEBUG`-trap limitation); boundaries and exit codes stay exact. | | PowerShell | `-Command ". '