Feature request: show when the current directory is a git worktree
Summary
More and more Claude Code workflows rely on git worktree (parallel agents, EnterWorktree, isolated branches per task). Today the git segment renders git:(<branch>) identically whether Claude runs in the main checkout or in a linked worktree.
When juggling several worktrees of the same repo, it's easy to lose track of where the session actually is — and that matters (e.g. a Docker stack that only mounts the main checkout, a dev server bound to one directory, uncommitted changes living in another tree).
Problem to Solve
The visual doesn't show if the current code is comming from a Worktree or not
Proposed Solution
Add a worktree indicator to the git segment, opt-in via config.
Detection
A directory is a linked worktree when --git-dir and --git-common-dir resolve to different paths:
git rev-parse --path-format=absolute --git-dir --git-common-dir
# main checkout : /repo/.git /repo/.git
# linked worktree: /repo/.git/worktrees/feat-x /repo/.git- One extra
git rev-parsecall (can be merged into a single invocation returning both lines), same 1s timeout asresolveGitRef. - Worktree name = basename of the
--git-dirpath (or basename of--show-toplevel). --path-format=absoluterequires git ≥ 2.31; fallback: resolve both relative paths againstcwdbefore comparing.
Rendering (suggestions)
| Situation | Current | Proposed |
|---|---|---|
| Main checkout | git:(master) |
git:(master) (unchanged) |
| Linked worktree | git:(feat/x) |
git:(feat/x) ⎇ wt |
| Linked worktree, with name | git:(feat/x) |
git:(feat/x) ⎇ feat-x |
Main checkout rendering stays untouched so existing users see no change.
Config
Alongside the existing gitStatus options (showDirty, showAheadBehind, showFileStats, branchOverflow):
{
"gitStatus": {
"showWorktree": false,
"worktreeStyle": "badge"
}
}showWorktree(boolean, defaultfalse) — enable the indicator.worktreeStyle("badge"|"name", default"badge") — short marker vs. worktree directory name.
Also exposed in /claude-hud:configure.
Implementation notes
getGitStatusinsrc/git.tswould return an extraworktree: { isLinked: boolean; name: string | null }field.- Detached HEAD (
detached:<sha>) and tag refs fromresolveGitRefkeep working as-is; the indicator is orthogonal to the ref. - Bare repos / non-git dirs: no indicator.
Happy to open a PR if the approach sounds good.
Source: jarrodwatts/claude-hud