Skip to content

Windows compatibility: bash/jq/PATH issues prevent statusline from working #8

Description

@Antoniaiaiaiaia

Problem

The statusline script does not work on Windows. After installation, Claude Code silently falls back to the default status bar — no error is shown, no custom output appears.

Root Causes

I traced through 4 separate issues that compound on Windows:

1. bash is not in the Windows system PATH

The installer sets the command as:

"command": "bash \"$HOME/.claude/statusline.sh\""

On Windows, bash is not a recognized command. The system PATH does not include Git Bash's bin directory. Windows does ship a bash.exe as part of WSL (Windows Subsystem for Linux), but if WSL has no distro installed, it just prints an error and exits.

2. Even with full path to Git Bash, tools are missing

Using the full path to Git Bash ("C:\Program Files\Git\usr\bin\bash.exe") gets the script running, but cat, jq, git, and other Unix tools are not found. This is because Git Bash's /usr/bin and /mingw64/bin directories are not in the PATH when bash.exe is invoked as a raw executable from Node.js (which goes through cmd.exe). Git Bash only sets up these paths when launched via --login or through its own shell shortcuts.

3. Home directory shortening fails due to path format mismatch

Claude Code sends cwd in Windows format: C:/Users/ROG/.claude
Git Bash's $HOME is in Unix format: /c/Users/ROG

The bash parameter expansion ${cwd/#$HOME_DIR/~} never matches because the formats differ.

4. Git Bash (MSYS2) bug with ${var/#pattern/replacement}

Even after normalizing both paths to the same format, bash's ${var/#pattern/replacement} silently fails when the pattern contains / characters on MSYS2/Git Bash. This was verified with hex dumps — the strings are byte-identical, but the substitution produces no change. Alternative approaches like [[ == ]] + substring or sed work fine.

Environment

  • Windows 10 (build 26200)
  • Claude Code v2.1.72
  • Git Bash 5.2.37 (MSYS2)
  • jq 1.7.1 (installed separately)
  • Node.js available in PATH

Solution

I rewrote the statusline as a Node.js script (statusline.js), which resolves all Windows issues:

  • node is guaranteed to be in PATH (Claude Code itself requires it)
  • No dependency on bash, jq, or Unix PATH setup
  • Native JSON.parse replaces jq
  • child_process.execSync for git operations
  • path module handles Windows/Unix path normalization
  • https module for the OAuth usage API call (with 60s file cache)

Settings config:

"statusLine": {
  "type": "command",
  "command": "node \"C:\\Users\\ROG\\.claude\\statusline.js\""
}

Result: Full statusline with model name, context usage, directory, git branch, token count, and rate limit bars — all working on Windows.

Suggestion

Consider either:

  1. Bundling a Node.js fallback in the installer for Windows (since node is always available where Claude Code runs)
  2. Adding --login flag to the bash invocation and using a normalize function for paths
  3. Documenting Windows limitations in the README

Happy to contribute a PR with the Node.js version if interested.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions