Skip to content

Custom statusLine command resets shell CWD between Bash tool calls #31471

Closed as not planned

Description

@vertexnick

Problem

When a custom statusLine command is configured in ~/.claude/settings.json, the shell's current working directory (CWD) no longer persists between Bash tool calls. Every cd command's effect is lost — the CWD resets to the project's primary working directory after each Bash invocation.

This makes it impossible to cd into a git worktree (or any subdirectory) and have subsequent Bash calls execute there.

Reproduction

  1. Add a statusLine to ~/.claude/settings.json:
    "statusLine": {
      "type": "command",
      "command": "bash ~/.claude/statusline-command.sh"
    }
  2. The script itself can be trivial (reads JSON from stdin, prints a formatted line).
  3. In a Claude Code session, run:
    • cd /some/other/directory → succeeds
    • pwd → reports /some/other/directory during that call, but the next Bash call reverts to the project root

Without the statusLine config, cd persists correctly across Bash calls as documented.

Investigation

  • The status line script (statusline-command.sh) does NOT itself run cd — it only reads stdin JSON and prints output via printf.
  • The issue appears to be that Claude Code executes the status line command in the same shell context between Bash tool calls, and this execution resets the shell's CWD to the project root.
  • This may be an artifact of how the shell subprocess is managed — possibly re-spawning or resetting the shell environment when invoking the status line command.

Expected Behavior

The status line command should not interfere with shell state (CWD, environment variables, etc.) between Bash tool calls. The status line command should either:

  • Run in an isolated subprocess/subshell that doesn't affect the main shell's state
  • Preserve and restore the CWD after executing the status line command
  • Run in a completely separate shell instance

Workaround

Remove the statusLine config from settings. Alternatively, use git -C <path> for git commands and absolute paths for file operations, but this defeats the purpose of cd persistence.

Environment

  • Platform: Windows 10 (git-bash shell)
  • Claude Code: latest

Activity

  1. github-actions commented on Apr 4, 2026

    @github-actions

    Closing for now — inactive for too long. Please open a new issue if this is still relevant.

  2. github-actions commented on Apr 12, 2026

    @github-actions

    This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

  3. locked as resolved and limited conversation to collaborators on Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions