Skip to content

Add Windows (Git Bash / MSYS2 / Cygwin) support for the system info block - #13

Open
AntaresGG wants to merge 1 commit into
clefspear:mainfrom
AntaresGG:windows-git-bash-support
Open

Add Windows (Git Bash / MSYS2 / Cygwin) support for the system info block#13
AntaresGG wants to merge 1 commit into
clefspear:mainfrom
AntaresGG:windows-git-bash-support

Conversation

@AntaresGG

Copy link
Copy Markdown

Running the bash greeting under Git for Windows (Git Bash) leaves most of the Space Vessel block empty and prints an error on every new shell.

Before

Welcome Aboard, Captain GK!

bash: uptime: command not found
Today is 2026.08.08, we are up and running for .

Space Vessel:
        OS: MINGW64_NT-10.0-26200 x86_64
        CPU:
        Memory:
        Net: IP Address: , Default Gateway:

After

Welcome Aboard, Captain GK!

Today is 2026.08.08, we are up and running for 6 days, 8 hours.

Space Vessel:
        OS: Windows 11 Enterprise 25H2 x86_64
        CPU: 12 processors, 6 cores, 12th Gen Intel(R) Core(TM) i5-12490F
        Memory: 64GB
        Net: IP Address: 10.0.0.9, Default Gateway: 10.0.0.1

Cause

_rkt_hw_info and _rkt_net_info branch on uname -s and only handle Darwin and Linux. Under MSYS-based bash that value is MINGW64_NT-10.0-26200 (or MSYS_NT-* / CYGWIN_NT-*), so neither branch runs and cpu_str, mem_str, ip and gw stay empty. Separately, Git Bash ships no uptime(1), so show_date_info writes an error to the terminal and leaves the uptime blank.

Changes

Three functions, one new MINGW*|MSYS*|CYGWIN* branch each:

  • _rkt_hw_info — MSYS exposes Linux-format /proc/cpuinfo and /proc/meminfo, so the CPU and memory parsing is the same as the Linux branch. The OS string comes from reg query on HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion (a single call, three values). Note that ProductName still reads Windows 10 Enterprise on Windows 11, so it is corrected via CurrentBuild >= 22000.
  • _rkt_net_info — parses the default-route row of route print -4 0.0.0.0, which yields the gateway and the local interface address in one shot. I picked route over ipconfig deliberately: that row is entirely numeric, so it is immune to the localized labels that break ipconfig parsing on non-English Windows (this machine is a zh-CN install). When several default routes exist, the lowest-metric one wins.
  • show_date_info — falls back to /proc/uptime when uptime(1) is absent, formatted as 6 days, 8 hours to match the shape of the existing uptime output.

Notes

  • The Darwin and Linux branches are untouched; the new code is additive.
  • Every lookup degrades to the previous empty-string behaviour if the underlying tool is missing from PATH, so nothing can regress into an error message.
  • Nothing here touches the PRNG, the palette generator, or the rendering path — cross-shell parity is unaffected.
  • Only bash/starcommand.sh is changed. The zsh greeting has the same platform gap, but I have no MSYS zsh to verify against, so I left it alone. Happy to extend this to zsh/zsh_greeting.zsh or to add a README/CHANGELOG note if you'd like.

Testing

Verified on Windows 11 Enterprise 25H2 (build 26200), Git for Windows, bash 5.3.15, zh-CN system locale:

  • bash -n bash/starcommand.sh passes.
  • Fresh interactive shells render all six fields with no stderr output.
  • Both the rocket_hw_cache.sh (24 h) and rocket_net_cache.sh (5 min) caches write and re-read correctly.
  • star, star list, star color, and star explore still behave as before.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XABWp1UM9qhnQn8PvQnyN3

On MSYS-based bash, `uname -s` returns MINGW64_NT-* (or MSYS_NT-* /
CYGWIN_NT-*), so neither the Darwin nor the Linux branch matched. The
greeting rendered empty CPU, Memory, IP and Gateway fields, and printed
`bash: uptime: command not found` on every new shell.

- _rkt_hw_info: reuse the Linux /proc parsing — MSYS ships Linux-format
  /proc/cpuinfo and /proc/meminfo — and read the product name from the
  registry. ProductName still reads "Windows 10" on Windows 11, so it is
  corrected via CurrentBuild >= 22000.
- _rkt_net_info: parse the default-route row of `route print -4 0.0.0.0`.
  That row is all numbers, so it survives the localized column headers
  that make `ipconfig` parsing unreliable on non-English Windows.
- show_date_info: fall back to /proc/uptime when uptime(1) is missing.

Every lookup degrades to the previous empty-string behaviour if the
underlying tool is unavailable. The Darwin and Linux branches are
untouched, and nothing here goes near the PRNG or the rendering path, so
cross-shell palette parity is unaffected.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XABWp1UM9qhnQn8PvQnyN3
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