Skip to content

fix(claude): correct path tilde and add PR number segment to statusline#36

Merged
fnayou merged 2 commits into
mainfrom
fix/claude-statusline-path-and-pr
Jun 24, 2026
Merged

fix(claude): correct path tilde and add PR number segment to statusline#36
fnayou merged 2 commits into
mainfrom
fix/claude-statusline-path-and-pr

Conversation

@fnayou

@fnayou fnayou commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Summary

Two fixes to the Claude Code statusline (stow/common/claude/.claude/statusline-command.sh):

  1. Path tilde — the home shortening rendered a literal backslash (\~/works/dotfiles) because the bash parameter-expansion replacement string kept the \ verbatim. Use a plain ~~/works/dotfiles.

  2. PR number segment — new GitHub segment showing the open PR number for the current branch (nf-fa-github icon + #N, mauve #c6a0f6):

    • gh pr view is a ~0.5s network call — too slow per render. Cached per repo+branch in ~/.cache/claude-statusline/ with a 120s TTL and refreshed in the background, so the statusline never blocks. The number appears one render after a branch first gains a PR.
    • Icon stored as an octal escape (\357\202\233) and printf'd, matching the OS-icon style.
    • Shows nothing when the branch has no open PR (closed/merged/none → empty cache).

Test

  • bash -n clean.
  • Path renders ~/works/dotfiles (no backslash).
  • On a worktree checked out to a branch with an open PR, the segment renders #34; branches without a PR render nothing.

Out of scope (noted, not changed)

The path-truncation code (lines ~37–41) uses negative array indices (${parts[-3]}), which need bash ≥4.3 — a pre-existing limitation, not introduced here.

fnayou added 2 commits June 24, 2026 12:59
Path segment rendered a literal backslash (\~) because the parameter-expansion replacement string kept it verbatim; use a plain ~ so it shows ~/path. Add a GitHub PR segment that displays the open PR number for the current branch (nf-fa-github icon + #N), cached per repo+branch with a 120s TTL and refreshed in the background so the ~0.5s 'gh' call never blocks rendering. Shows nothing when the branch has no open PR.
@fnayou fnayou merged commit 31a8038 into main Jun 24, 2026
2 checks passed
@fnayou fnayou deleted the fix/claude-statusline-path-and-pr branch June 24, 2026 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant