From 2f75da8da366cdec92a084152d3c761a893ad906 Mon Sep 17 00:00:00 2001 From: dietrich ayala Date: Tue, 18 Aug 2026 15:39:47 +0200 Subject: [PATCH] Show the literal working directory in the statusline place indicator The indicator named the tree by basename, which is derived from the working directory rather than being it, and went on showing the tree root when the session sat below it. Showing the path itself, home abbreviated, makes the line confirm what every other mechanism actually reads. Classification still comes from the toplevel, so a directory below a worktree root reads as that track, and the handoff marker still refers to the tree root. --- statusline.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/statusline.sh b/statusline.sh index 597c854..7a1ff16 100755 --- a/statusline.sh +++ b/statusline.sh @@ -35,6 +35,10 @@ green=$'\033[32m'; yellow=$'\033[33m'; red=$'\033[31m' # test โ€” no need to know the project's declared worktrees directory. place="" if [ -n "$dir" ]; then + # The literal working directory, home abbreviated. Shown rather than a name + # derived from it, so what's on screen is the thing every other mechanism + # reads โ€” including when cwd sits below the tree root. + pretty="${dir/#${HOME:-/nonexistent}/\~}" gitinfo=$(git -C "$dir" rev-parse --show-toplevel --git-dir --git-common-dir 2>/dev/null) if [ -n "$gitinfo" ]; then { IFS= read -r top; IFS= read -r gitdir; IFS= read -r commondir; } <<< "$gitinfo" @@ -43,14 +47,13 @@ if [ -n "$dir" ]; then hand=""; [ -f "$top/handoff.md" ] && hand=" +handoff" if [ "$gitdir" != "$commondir" ]; then # Linked worktree: a track. Its handoff.md belongs to this work alone. - repo=$(basename "$(dirname "$commondir")") - place="${green}track ${repo}/$(basename "$top")${reset}${dim}${hand}${reset}" + place="${green}track ${pretty}${reset}${dim}${hand}${reset}" else # Primary checkout: handoff.md here is the track roster, which is a # normal thing to find. What's worth flagging is the inverse โ€” live # tracks with nothing coordinating them. n=$(git -C "$dir" worktree list 2>/dev/null | tail -n +2 | grep -c .) - place="${yellow}primary $(basename "$top")${reset}" + place="${yellow}primary ${pretty}${reset}" if [ "$n" -gt 0 ]; then noun="tracks"; [ "$n" -eq 1 ] && noun="track" place="${place}${dim} ยท ${n} ${noun}${reset}" @@ -59,7 +62,7 @@ if [ -n "$dir" ]; then [ -n "$hand" ] && place="${place}${dim}${hand}${reset}" fi else - place="${dim}$(basename "$dir") (no repo)${reset}" + place="${dim}${pretty} (no repo)${reset}" fi fi -- 2.51.2