Skip to content

feat: add Windows platform support#106

Merged
stephenleo merged 4 commits intostephenleo:mainfrom
tkm3d1a:feat/windows-support
Mar 28, 2026
Merged

feat: add Windows platform support#106
stephenleo merged 4 commits intostephenleo:mainfrom
tkm3d1a:feat/windows-support

Conversation

@tkm3d1a
Copy link
Copy Markdown
Contributor

@tkm3d1a tkm3d1a commented Mar 15, 2026

Summary

  • Add cross-platform home_dir() helper to platform.rs that resolves the user's home directory via CLAUDE_HOME > HOME > USERPROFILE, enabling Windows compatibility without breaking existing Linux/macOS behavior
  • Add get_oauth_token() for Windows that reads ~/.claude/.credentials.json directly (Claude Code on Windows stores credentials as a JSON file, no keychain needed)
  • Remove the compile_error! that previously rejected non-macOS/Linux build targets
  • Gate Unix-only functions (get_oauth_token_with_cmd, install_hint) and their tests behind cfg(not(target_os = "windows"))
  • Update config.rs global config discovery to use platform::home_dir() instead of hardcoded $HOME env var
  • Update uninstall.rs to use home_dir() and platform-appropriate binary paths (.exe suffix on Windows)
  • Add install.ps1 PowerShell installer that downloads the release binary, optionally adds to PATH, writes a default cship.toml, and registers the statusline in Claude Code's settings.json

Motivation

cship currently only compiles on macOS and Linux. Claude Code runs on Windows (natively and via Git Bash), and Windows users have no way to use cship. This PR adds first-class Windows support with minimal changes to existing code paths — all Linux/macOS behavior is unchanged.

CI / Release considerations

This PR does not modify CI configuration. To fully support Windows users, the following would also be needed:

  • Add windows-latest to the CI test matrix
  • Add x86_64-pc-windows-msvc (and optionally aarch64-pc-windows-msvc) to the release build targets so install.ps1 can download a binary

These can be done in a follow-up PR or added to this one if preferred.

Test plan

  • cargo check --target x86_64-pc-windows-msvc compiles cleanly
  • cargo test passes on Linux/macOS (no regressions — Unix-only tests are cfg-gated)
  • cargo test passes on Windows (platform-gated tests are skipped)
  • install.ps1 downloads binary, writes config, and registers statusline on a fresh Windows machine
  • cship uninstall correctly removes Windows binary paths (.exe)
  • Global config discovery works with USERPROFILE when HOME is unset (native Windows shell)

🤖 Generated with Claude Code

- Add home_dir() helper that resolves home directory cross-platform
  (CLAUDE_HOME > HOME > USERPROFILE) for Windows compatibility
- Add Windows get_oauth_token() that reads ~/.claude/.credentials.json
  directly (no keychain/secret-tool needed on Windows)
- Remove compile_error! that rejected non-macOS/Linux targets
- Gate Unix-only helpers and tests behind cfg(not(target_os = "windows"))
- Update config.rs global fallback to use platform::home_dir() instead
  of hardcoded $HOME env var
- Update uninstall.rs to use home_dir() and Windows binary paths (.exe)
- Add install.ps1 PowerShell installer for Windows (downloads binary,
  configures PATH, writes default config, registers statusline)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tkm3d1a tkm3d1a marked this pull request as ready for review March 15, 2026 20:48
@stephenleo
Copy link
Copy Markdown
Owner

stephenleo commented Mar 18, 2026

@tkm3d1a Thanks for your submission! Give me sometime to test this out on a windows PC. Can you please look into the CI error? https://github.com/stephenleo/cship/actions/runs/23118985383/job/67521158086?pr=106

@tkm3d1a
Copy link
Copy Markdown
Contributor Author

tkm3d1a commented Mar 19, 2026

@stephenleo Of course - I fixed the CI error, it was a clippy error just collapsed a nested if statement in src/platform.rs

tkm3d1a and others added 2 commits March 21, 2026 10:24
- uninstall: use platform-appropriate binary name (cship.exe on Windows)
- passthrough/cli: gate fake-starship tests with #[cfg(unix)] since
  Command::new resolves only .exe, not .cmd/.bat on Windows

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Owner

@stephenleo stephenleo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. tested on windows powershell

@stephenleo stephenleo merged commit 7549917 into stephenleo:main Mar 28, 2026
2 of 3 checks passed
@stephenleo
Copy link
Copy Markdown
Owner

thank you for your submission! I had some trouble from my own in experience with powershell but tested it fine. I'll update docs.

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.

2 participants