Skip to content

feat(prompt): built-in Git Bash compatible factory default on Windows - #292

Merged
caomengxuan666 merged 5 commits into
masterfrom
feat/gitbash-default-theme
Oct 13, 2026
Merged

caomengxuan666 merged 5 commits into
masterfrom
feat/gitbash-default-theme

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Owner adjudication 2026-10-12 (structure, colors, red lines) + 2026-10-13 (git2 library dependency, option d). The previous attempt at this branch died at the rate limit with zero commits — rebuilt from the adjudication record.

The factory default prompt on Windows is now the Git Bash skeleton users already know:

green user@host  yellow /c/...-cwd  cyan branch[*]  $
  • The MINGW64 environment segment is deliberately omitted (MinGW identity, not ours); no static product tag either — a single-environment shell has no disambiguation need, identity lives in the banner/niu --version.
  • Zero git child processes (niubash#145 red line): the branch/dirty segment reads through git2 (Windows-target-only compile, default-features = false — no network stack). Latency on a real repository: cold 39ms, warm p50 2.5ms / p90 3.7ms, vs Git Bash's per-prompt __git_ps1 fork (~100-300ms) — the smoother-than-them deliverable, measured.
  • Dirty state = worktree/index changes + conflicts, marked * like __git_ps1. Detached HEAD shows the short SHA. Outside a repository the segment is empty.
  • Claims still win: a PS1/theme claim displaces the floor per prompt; set -o vi keeps the live editing-mode indicator (niubash#184 surface — the indicator strings follow the new factory prompt char).
  • Windows-only: the theme does not exist off-Windows (a config naming it there falls back to the template floor); the git2 dependency compiles only for Windows targets — unix cfg-strip stays clean ([P1][history][历史污染残留] 双会话同文命令被内容去重吞掉一份(丢失) #570 precedent).

Tests: git_prompt unit matrix (branch/dirty/detached/~ abbreviation/drive persona/120ms budget) 8/8; real-ConPTY factory-prompt scenario incl. cd into a repository; vi floor indicator updated to the factory char; runtime lib 473 green; interactive 43/44 (the 1 is the pre-existing ctrl_d_after_background_job_exits baseline, red on clean master too).

Follow-up (not in this PR): the setup wizard's theme question should describe the Skip option as "Git Bash compatible (built-in default)" on Windows.

… (owner adjudication 2026-10-12)

The factory default prompt on Windows is now the Git Bash skeleton:
green user@host, yellow POSIX-persona cwd, cyan branch (+ dirty *) and
`$ ` — the MINGW64 environment segment is deliberately omitted (that is
MinGW identity) and there is no static product tag (single-environment
shells have no disambiguation need; identity lives in the banner).

The branch/dirty segment reads the repository through git2
(owner-approved library dependency, adjudication option d;
Windows-target-only compile) instead of a git child process — the
prompt path never spawns (niubash#145 red line). Measured on this
machine against a real repository: cold 39ms, warm p50 2.5ms / p90
3.7ms per prompt, versus Git Bash's per-prompt __git_ps1 fork
(~100-300ms).

Claims still win: a PS1/theme claim displaces the floor per prompt
(prompt_slot_claimed check in prompt_for_display), set -o vi keeps the
live editing-mode indicator (niubash#184 surface), and the theme does
not exist off-Windows — a config naming it there falls back to the
template floor, keeping the unix cfg-strip clean (#570 precedent).

Tests: git_prompt unit matrix (branch/dirty/detached/tilde/persona/
budget), real-ConPTY factory-prompt scenario incl. cd into a repo, and
the vi floor indicator updated to the new factory prompt char.
The unix acceptance lanes caught it: the module declaration had no cfg
gate, so unix targets compiled src/git_prompt.rs against the
Windows-only git2 dependency (E0433). Same #570 discipline as the rest
of the theme.
…false positive

"echo two".contains("cho two") is true by substring semantics (the
editor echo of the input line contains it), so the probe failed on
healthy shells too. Execution-level verification (flush trace, submit
buffer, arithmetic-mark outputs) shows the paste bytes intact on
current master; the real paste defects are #308 (fixed by #309) and
the owner-machine investigation tracked in #291.
The unix -D warnings lanes flag gitbash_prompt_active as never-read
(the refresh site is cfg'd out there); cfg_attr keeps the field for
the Windows state machine while silencing the unix dead-code leg.
@caomengxuan666
caomengxuan666 merged commit d3ed3a8 into master Oct 13, 2026
9 checks passed
@caomengxuan666
caomengxuan666 deleted the feat/gitbash-default-theme branch October 13, 2026 08:44
caomengxuan666 added a commit that referenced this pull request Oct 13, 2026
…1.4.0 section (#326)

- The [Unreleased] entries (#284/#287, #293-#304, #313) move into
  [1.4.0]; [Unreleased] is empty again.
- Newly recorded (today's wave): Git Bash compatible factory default
  prompt (#292, headline), WT-form shortcuts (#290/#211), the paste
  burst trailing-Enter fix (#308/#291), self-update SHA256 + release
  pinning (#311/#312), managed-block convergence (#324), completion
  tables/NIU_COMPDEFS/NIU_ENV probe (#305-#307), -s on-demand stdin
  (rubash#586 host half), bash/rbash invocation faces (#321/#322).
- Older gaps recorded: closed-stdout pipe contract (#245/#286), history
  session-end write-back (#265), sh POSIX contract (#262), PWD persona
  alignment (#283), one-shot fast path (#270), --cwd-state (#272),
  --encoded-command (#271), REPL-command highlighting (#281), docs
  passes (#255/#225/#226/#227), MSRV (#267), easter-egg prune (#264).

CHANGELOG-only change; no version claims.
caomengxuan666 added a commit that referenced this pull request Oct 14, 2026
…erer into the segments engine (closes #331) (#332)

The oh-my-niu bundle's prompts/segments.toml declares
[segments.git] id = vcs; the segments engine had no Vcs variant —
a socket with no power. This lands the native segment for 1.4.1:

- SegmentId::Vcs; from_name accepts vcs (the native id) and git
  (the bundle segment name), case/separator-insensitive as before.
- Rendering goes through #292's in-process git2 renderer:
  git_prompt::branch_segment is now pub. branch / branch* / short-SHA
  detached, empty outside a repository. Zero child processes on the
  prompt path (niubash#145 red line; #604 measured PS1-embedded
  $(...) at ~100x native cost). Off-Windows the segment renders
  empty, matching the gitbash style's template fallback there.
- Colour contract from the oh-my-niu themes: [git_clean] cyan,
  [git_dirty] yellow, keyed off the renderer's dirty star, applied
  regardless of preset (detached SHA renders clean-cyan, #292 style).
- Perf: segment render p50 <= 10ms asserted (21-sample median,
  10x headroom); measured warm p50 2.38ms / p90 2.47ms on the dev
  box, consistent with #292's 2.5ms.
- Contract tests pin a verbatim mirror of the bundle's
  prompts/segments.toml: every declared id resolves natively and
  every shipped preset element resolves through the name->id map
  (the lean preset's git lands on SegmentId::Vcs).
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.

1 participant