Skip to content

feat: add optional workdir suffix for worktree disambiguation#2

Merged
balgaly merged 1 commit into
mainfrom
feat/workdir-display
Apr 30, 2026
Merged

feat: add optional workdir suffix for worktree disambiguation#2
balgaly merged 1 commit into
mainfrom
feat/workdir-display

Conversation

@balgaly
Copy link
Copy Markdown
Owner

@balgaly balgaly commented Apr 30, 2026

Summary

  • Adds CFG_SHOW_WORKDIR, CFG_WORKDIR_STYLE, CFG_WORKDIR_MAX_LEN in both statusline.sh and statusline.ps1 (parity across shells).
  • Line 1 renders as repo ▸ workdir in dim text when the workdir differs; the default worktree style is a no-op for single-worktree users.
  • Four styles: full, relative (~-prefixed), basename, worktree (basename only when it differs from repo name — the user's case).
  • Long paths are left-truncated with so the worktree-specific tail always survives: …/code-koala-worktrees/p01-numbered-diffs.

Motivation: running many git worktrees off the same repo makes location_name (repo name) identical across them. The existing statusline gave no indication which worktree you were in.

Test plan

  • New test suite test/test-workdir.sh — 11 tests covering all four styles, the disabled flag, single-worktree no-op, linked-worktree basename surfacing, and left-truncation preserving the tail.
  • Existing suites still green: test-statusline-v2.sh (11), test-hooks.sh (7), test-brif-pane.sh (20). 49 tests total pass.
  • PowerShell manual smoke test: verified full / relative / basename / worktree styles, home-dir ~ substitution works even when \$env:USERPROFILE and JSON-supplied cwd use different slash conventions.
  • CI run on this PR.

Non-changes

  • No change to other line-1 fields, colors, or layout.
  • No worktree detection logic (as specified in the task brief — the worktree style is a simple basename-vs-repo-name comparison).
  • No new JSON input fields.

🤖 Generated with Claude Code

Adds CFG_SHOW_WORKDIR, CFG_WORKDIR_STYLE (full/relative/basename/worktree),
and CFG_WORKDIR_MAX_LEN to both statusline.sh and statusline.ps1. Renders as
"repo ▸ workdir" on line 1 with left-truncation that preserves the
worktree-specific tail. The worktree style (default) shows the cwd basename
only when it differs from the repo name — single-worktree users see no
change. Adds test/test-workdir.sh (11 tests) exercising all four styles,
the disabled flag, and truncation. Updates README + CHANGELOG.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@balgaly balgaly merged commit b8668d2 into main Apr 30, 2026
1 check passed
@balgaly balgaly deleted the feat/workdir-display branch April 30, 2026 12:29
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