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