Skip to content

fix(zsh): start the window manager above the p10k instant prompt - #211

Open
ipproyectosysoluciones wants to merge 1 commit into
Gentleman-Programming:mainfrom
ipproyectosysoluciones:fix/zsh-wm-autostart-above-p10k
Open

ipproyectosysoluciones wants to merge 1 commit into
Gentleman-Programming:mainfrom
ipproyectosysoluciones:fix/zsh-wm-autostart-above-p10k

Conversation

@ipproyectosysoluciones

Copy link
Copy Markdown

What

Moves the window-manager launcher (start_if_needed) and its call to the top of the Zsh template, above the powerlevel10k instant-prompt block.

Closes #210.

Why

The instant prompt runs the rest of .zshrc in a subshell with stdout redirected, where [[ -t 1 ]] is false (the guard bails out) and an exec would only replace that subshell — so the WM (tmux, zellij or herdr) never autostarted and the terminal was left with a plain shell. Measurements and the reproduction are in #210.

Changes

  • GentlemanZsh/.zshrc: launcher definition + call moved above the instant prompt, with a comment explaining the constraint so it does not get moved back.
  • installer/internal/system/zsh_template_test.go (new):
    • TestZshTemplateLaunchesWMBeforeP10kInstantPrompt — the template keeps the launcher above the instant prompt (skips if p10k is ever dropped).
    • TestPatchZshForWMKeepsLauncherAboveInstantPrompt — patches the real template for tmux/zellij/herdr and asserts PatchZshForWM preserves the order and still selects the chosen WM.

Verification

  • zsh -n GentlemanZsh/.zshrc → syntax valid.
  • Launcher above the instant prompt, with a real terminal: opening a terminal starts the WM on its own (no manual command), confirmed in the WM's own log.
  • go test ./internal/system/ ./internal/tui/trainer/ ./cmd/... → pass.

Not in this PR

The TUI golden tests (TestWelcomeScreenGolden, TestMainMenuGolden, TestOSSelectGolden) fail on Linux because they expect a macOS-detected frame. Pre-existing on main, unrelated to this fix — happy to send a separate PR if useful.

Note for existing installs

An already-installed ~/.zshrc keeps the old order until the template is copied again (re-running the installer). Related: #206, about preserving local Zsh customizations across updates.

The WM launcher (`start_if_needed`) sat below powerlevel10k's instant-prompt
block. That block runs the rest of the file in a subshell with stdout
redirected, where `[[ -t 1 ]]` is false and an `exec` would only replace the
subshell -- so the window manager (tmux, zellij or herdr) never started and the
terminal was left with a plain shell. The p10k comment directly above the block
already states that code needing a real terminal must go above it.

The launcher definition and its call now live at the top of the template, ahead
of the instant prompt, with a comment explaining the constraint.

Tests added (`installer/internal/system/zsh_template_test.go`): one asserts the
template keeps the launcher above the instant prompt, the other patches the
real template for each WM and asserts `PatchZshForWM` preserves that order.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(zsh): the window manager never autostarts while powerlevel10k's instant prompt is enabled

1 participant