Skip to content

Commit ec7a7bc

Browse files
yepzdkclaude
andcommitted
feat: add project name segment to itkdev-statusline
Show the project name as the leftmost bold segment in the statusline for easier identification of multiple Claude Code sessions. Derives name from git remote origin URL, falling back to workspace.project_dir or cwd basename for non-git projects. Co-authored-by: Claude <noreply@anthropic.com>
1 parent c43abfd commit ec7a7bc

3 files changed

Lines changed: 39 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- Project name segment in `itkdev-statusline` showing git repo name (or folder name) for easier session identification
1213
- `itkdev-statusline` extension with context window usage, git branch, and plan progress display
1314

1415
### Fixed

extensions/itkdev-statusline/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ Claude Code statusline plugin showing git branch, plan progress, and context win
55
## What it shows
66

77
```
8-
feat/auth │ 2/5 │ ▰▰▰▰▰▱▱▱▱▱ 45%
8+
itkdev-claude-plugins │ feat/auth │ 2/5 │ ▰▰▰▰▰▱▱▱▱▱ 45%
99
```
1010

1111
| Segment | Source | Notes |
1212
|---------|--------|-------|
13-
| Git branch | `.git/HEAD` in `cwd` | Handles detached HEAD (short hash) |
14-
| Plan progress | `docs/plans/*.md` in `cwd` | Newest non-VERIFIED plan, checkbox counts |
13+
| Project name | Git remote origin / `workspace.project_dir` / `cwd` basename | Bold. Identifies the session. |
14+
| Git branch | `.git/HEAD` in project root | Handles detached HEAD (short hash) |
15+
| Plan progress | `docs/plans/*.md` in project root | Newest non-VERIFIED plan, checkbox counts |
1516
| Context % | stdin JSON `context_window.remaining_percentage` | 10-segment progress bar, color coded. Falls back to `used_percentage`. |
1617

1718
### Context color thresholds

extensions/itkdev-statusline/bin/statusline.sh

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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
1212
cwd="${tsv%%$'\t'*}"
1313
rest="${tsv#*$'\t'}"
1414
pct="${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

2325
segments=()
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"
2756
if [[ -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
3968
fi
4069

4170
# ── Plan progress ──────────────────────────────────────────────────────
42-
plan_dir="${cwd}/docs/plans"
71+
plan_dir="${proj_root}/docs/plans"
4372
if [[ -d "$plan_dir" ]]; then
4473
# Find the newest non-VERIFIED plan file.
4574
newest_plan=""

0 commit comments

Comments
 (0)