@@ -8,11 +8,13 @@ set -euo pipefail
88# Parse cwd and context percentage from stdin JSON via a single jq call.
99# Prefer remaining_percentage (matches Claude Code's native context display)
1010# over used_percentage, which excludes reserved overhead and can differ.
11- tsv=$( jq -r ' [(.cwd // ""), (if (.context_window.remaining_percentage // null) != null then (100 - .context_window.remaining_percentage) | floor else (.context_window.used_percentage // 0) end), (.transcript_path // "")] | @tsv' 2> /dev/null) || true
11+ tsv=$( jq -r ' [(.cwd // ""), (if (.context_window.remaining_percentage // null) != null then (100 - .context_window.remaining_percentage) | floor else (.context_window.used_percentage // 0) end), (.transcript_path // ""), (.workspace.project_dir // "") ] | @tsv' 2> /dev/null) || true
1212cwd=" ${tsv%% $' \t ' * } "
1313rest=" ${tsv#* $' \t ' } "
1414pct=" ${rest%% $' \t ' * } "
15- transcript=" ${rest#* $' \t ' } "
15+ rest2=" ${rest#* $' \t ' } "
16+ transcript=" ${rest2%% $' \t ' * } "
17+ project_dir=" ${rest2#* $' \t ' } "
1618
1719# Bail if we got nothing useful.
1820[[ -z " ${cwd:- } " ]] && exit 0
@@ -22,24 +24,51 @@ pct="${pct:-0}"
2224
2325segments=()
2426
27+ # ── Project identifier ───────────────────────────────────────────────
28+ # Prefer workspace.project_dir over cwd (avoids subdirectory basenames).
29+ proj_root=" ${project_dir:- $cwd } "
30+ project_name=" "
31+
32+ # Try git remote origin name first (more meaningful than directory name).
33+ git_config=" ${proj_root} /.git/config"
34+ if [[ -f " $git_config " ]]; then
35+ while IFS= read -r line; do
36+ case " $line " in
37+ * url\ =* )
38+ remote_url=" ${line##* = } "
39+ project_name=" ${remote_url##*/ } "
40+ project_name=" ${project_name% .git} "
41+ break
42+ ;;
43+ esac
44+ done < " $git_config "
45+ fi
46+
47+ # Fall back to directory basename.
48+ : " ${project_name:= ${proj_root##*/ } } "
49+
50+ if [[ -n " $project_name " ]]; then
51+ segments+=($' \033 [1m' " ${project_name} " $' \033 [0m' )
52+ fi
53+
2554# ── Git branch ─────────────────────────────────────────────────────────
26- head_file=" ${cwd } /.git/HEAD"
55+ head_file=" ${proj_root } /.git/HEAD"
2756if [[ -f " $head_file " ]]; then
2857 head_content=$( < " $head_file " )
2958 if [[ " $head_content " == ref:\ * ]]; then
3059 branch=" ${head_content# ref: refs/ heads/ } "
3160 else
3261 branch=" ${head_content: 0: 7} " # detached HEAD — short hash
3362 fi
34- if [[ -z " $( git -C " $cwd " status --porcelain 2> /dev/null) " ]]; then
63+ if [[ -z " $( git -C " $proj_root " status --porcelain 2> /dev/null) " ]]; then
3564 segments+=($' \033 [32m' " ${branch} " $' \033 [0m' ) # green = clean
3665 else
3766 segments+=($' \033 [31m' " ${branch} " $' \033 [0m' ) # red = dirty
3867 fi
3968fi
4069
4170# ── Plan progress ──────────────────────────────────────────────────────
42- plan_dir=" ${cwd } /docs/plans"
71+ plan_dir=" ${proj_root } /docs/plans"
4372if [[ -d " $plan_dir " ]]; then
4473 # Find the newest non-VERIFIED plan file.
4574 newest_plan=" "
0 commit comments