Skip to content

Commit a931d3f

Browse files
rysweetUbuntuclaude
authored
feat: Add repository URI to statusline after branch name (#1977)
Adds the git repository URI to the statusline display, positioned directly after the branch name indicator. Changes: - Extract repository URL using 'git remote get-url origin' - Format URI by removing protocol prefix (https://, git@) and .git suffix - Display shortened URI in brackets with cyan color: [github.com/user/repo] - Gracefully handle repos without remotes (no display if no remote) - Works correctly in both main repository and worktrees Testing: - Tested with HTTPS URLs: displays correctly - Tested with SSH URLs: formats properly ([email protected]:user/repo → github.com/user/repo) - Tested in worktree directory: works as expected - Tested in main repository: displays correctly - No regressions in existing indicators Documentation: - Updated STATUSLINE.md indicators table with new Repository URI entry - Updated examples to show new URI display format - Added breakdown explanations for repository indicator Fixes #1976 Co-authored-by: Ubuntu <azureuser@amplihack-dev20260113b.ifi1khzsiemuxl451rqpm2jdhd.ex.internal.cloudapp.net> Co-authored-by: Claude Sonnet 4.5 <[email protected]>
1 parent 4ad4877 commit a931d3f

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

.claude/tools/statusline.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ esac
8282

8383
# Git info
8484
git_info=""
85+
repo_uri_str=""
8586
if git rev-parse --is-inside-work-tree &>/dev/null; then
8687
branch=$(git symbolic-ref --quiet --short HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)
8788
if [ -n "$branch" ]; then
@@ -101,6 +102,14 @@ if git rev-parse --is-inside-work-tree &>/dev/null; then
101102
else
102103
git_info=" \033[${git_color}m($branch$dirty_marker)\033[0m"
103104
fi
105+
106+
# Get repository URI (shortened format)
107+
repo_url=$(git remote get-url origin 2>/dev/null)
108+
if [ -n "$repo_url" ]; then
109+
# Remove protocol prefix and .git suffix for cleaner display
110+
repo_short=$(echo "$repo_url" | sed -e 's|^https://||' -e 's|^http://||' -e 's|^git@||' -e 's|:|/|' -e 's|\.git$||')
111+
repo_uri_str=" \033[36m[$repo_short]\033[0m"
112+
fi
104113
fi
105114
fi
106115

@@ -257,4 +266,4 @@ if [ -n "$session_id" ]; then
257266
fi
258267

259268
# Output status line
260-
echo -e "\033[32m$display_dir\033[0m$git_info \033[${model_color}m$model_name\033[0m$tokens_str 💰\$$cost_formatted$duration_str$agents_str$power_steering_str$lock_str"
269+
echo -e "\033[32m$display_dir\033[0m$git_info$repo_uri_str \033[${model_color}m$model_name\033[0m$tokens_str 💰\$$cost_formatted$duration_str$agents_str$power_steering_str$lock_str"

docs/reference/STATUSLINE.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The statusline shows progress, costs, context usage, and active features for you
1212
| --------------------- | ------------------------- | ------------------------------------------- | ------------------------------------------------------- |
1313
| **Directory** | Current working directory | `~/path` | `~` = home directory |
1414
| **Git Branch** | Branch name and status | `(branch → remote)` or `(branch* → remote)` | `*` = uncommitted changes, Cyan = clean, Yellow = dirty |
15+
| **Repository URI** | Git remote repository URL | `[github.com/user/repo]` | Shortened format (cyan), only if remote exists |
1516
| **Model** | Active Claude model | `Opus`, `Sonnet`, `Haiku` | Red=Opus, Green=Sonnet, Blue=Haiku |
1617
| **Tokens** 🎫 | Total token usage | `234K`, `1.2M`, or raw number | M=millions, K=thousands |
1718
| **Cost** 💰 | Total session cost | `$1.23` | USD |
@@ -43,13 +44,14 @@ The statusline shows progress, costs, context usage, and active features for you
4344
### Example 1: Clean Development Session
4445

4546
```
46-
~/src/amplihack4 (main → origin) Sonnet 🎫 234K 💰$1.23 ⏱12m
47+
~/src/amplihack4 (main → origin) [github.com/rysweet/amplihack] Sonnet 🎫 234K 💰$1.23 ⏱12m
4748
```
4849

4950
**Breakdown:**
5051

5152
- **Directory**: `~/src/amplihack4` (~= home shorthand)
5253
- **Git**: `(main → origin)` cyan = clean branch
54+
- **Repository**: `[github.com/rysweet/amplihack]` cyan = repository URL
5355
- **Model**: `Sonnet` green = Sonnet family
5456
- **Tokens**: `🎫 234K` 234,000 tokens
5557
- **Cost**: `💰$1.23` $1.23 USD
@@ -58,13 +60,14 @@ The statusline shows progress, costs, context usage, and active features for you
5860
### Example 2: Active Development with Features
5961

6062
```
61-
~/projects/api (feature/auth* → origin) Opus 🎫 1.2M 💰$15.67 ⏱1h 🚦×3 🔒×5
63+
~/projects/api (feature/auth* → origin) [github.com/org/api-service] Opus 🎫 1.2M 💰$15.67 ⏱1h 🚦×3 🔒×5
6264
```
6365

6466
**Breakdown:**
6567

6668
- **Directory**: `~/projects/api`
6769
- **Git**: `(feature/auth* → origin)` yellow = dirty, `*` = uncommitted changes
70+
- **Repository**: `[github.com/org/api-service]` cyan = repository URL
6871
- **Model**: `Opus` red = Opus family
6972
- **Tokens**: `🎫 1.2M` 1.2 million tokens
7073
- **Cost**: `💰$15.67` $15.67 USD

0 commit comments

Comments
 (0)