diff --git a/statusline.sh b/statusline.sh index 7a1ff16..54e94b6 100755 --- a/statusline.sh +++ b/statusline.sh @@ -35,9 +35,9 @@ 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. + # Fallback for a directory git knows nothing about: the path itself, home + # abbreviated. Inside a repo the tree gets named instead, since the constant + # `~/workspace/` and `.worktrees/` prefixes carry nothing. pretty="${dir/#${HOME:-/nonexistent}/\~}" gitinfo=$(git -C "$dir" rev-parse --show-toplevel --git-dir --git-common-dir 2>/dev/null) if [ -n "$gitinfo" ]; then @@ -45,15 +45,20 @@ if [ -n "$dir" ]; then # Marker for a handoff.md already sitting in this tree: writing one here # edits that file, and /pickup reads it. hand=""; [ -f "$top/handoff.md" ] && hand=" +handoff" + # Where the session sits relative to the tree root: empty at the root, + # "/lib" below it. The tree is what classifies the session, the remainder is + # what a bare tree name would hide. + sub="${dir#"$top"}" if [ "$gitdir" != "$commondir" ]; then # Linked worktree: a track. Its handoff.md belongs to this work alone. - place="${green}track ${pretty}${reset}${dim}${hand}${reset}" + repo=$(basename "$(dirname "$commondir")") + place="${green}track ${repo}/$(basename "$top")${sub}${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 ${pretty}${reset}" + place="${yellow}primary $(basename "$top")${sub}${reset}" if [ "$n" -gt 0 ]; then noun="tracks"; [ "$n" -eq 1 ] && noun="track" place="${place}${dim} ยท ${n} ${noun}${reset}"