1
1
Fork
You've already forked kurama
0

feat: show current git branch in the TUI status bar #14

Closed
opened 2026年07月10日 14:22:46 +02:00 by andeerc · 0 comments

Summary

When working inside a git repository, display the current branch name in the TUI (e.g. in the status bar or header), so the user always knows which branch Nibble is operating on.

Motivation

Nibble frequently reads, writes, and executes code in the working directory. Knowing which git branch is active at a glance prevents accidental changes on the wrong branch — especially during longer sessions where the user may have switched branches in another terminal.

Proposed Behavior

  • Detect whether the current working directory is inside a git repository on startup

  • If it is, resolve the current branch name (or commit SHA if in detached HEAD state)

  • Display it in the TUI status bar alongside other session info, e.g.:

    nibble main 󰘬 coder gpt-4o

  • Update the branch indicator if the branch changes mid-session (e.g. the user runs git checkout via the bash tool or in another terminal)

Display Details

  • Show the branch name prefixed with a git icon (e.g. , , or (git) as fallback for terminals without Nerd Fonts)
  • If in detached HEAD state, show the short commit SHA instead (e.g. HEAD a1b2c3d)
  • If not inside a git repo, show nothing (no placeholder or empty label)

Implementation Notes

  • Use git rev-parse --abbrev-ref HEAD to get the branch name; returns HEAD when detached
  • For detached HEAD: follow up with git rev-parse --short HEAD to get the SHA
  • Consider polling or watching .git/HEAD for changes to keep the indicator live during a session
  • The git detection logic could live in a small utility alongside or inside internal/filetracker or a new internal/git package
## Summary When working inside a git repository, display the current branch name in the TUI (e.g. in the status bar or header), so the user always knows which branch Nibble is operating on. ## Motivation Nibble frequently reads, writes, and executes code in the working directory. Knowing which git branch is active at a glance prevents accidental changes on the wrong branch — especially during longer sessions where the user may have switched branches in another terminal. ## Proposed Behavior - Detect whether the current working directory is inside a git repository on startup - If it is, resolve the current branch name (or commit SHA if in detached HEAD state) - Display it in the TUI status bar alongside other session info, e.g.: ` nibble main 󰘬 coder gpt-4o ` - Update the branch indicator if the branch changes mid-session (e.g. the user runs `git checkout` via the bash tool or in another terminal) ## Display Details - Show the branch name prefixed with a git icon (e.g. ` `, ` `, or `(git)` as fallback for terminals without Nerd Fonts) - If in detached HEAD state, show the short commit SHA instead (e.g. `HEAD a1b2c3d`) - If not inside a git repo, show nothing (no placeholder or empty label) ## Implementation Notes - Use `git rev-parse --abbrev-ref HEAD` to get the branch name; returns `HEAD` when detached - For detached HEAD: follow up with `git rev-parse --short HEAD` to get the SHA - Consider polling or watching `.git/HEAD` for changes to keep the indicator live during a session - The git detection logic could live in a small utility alongside or inside `internal/filetracker` or a new `internal/git` package
Sign in to join this conversation.
No Branch/Tag specified
main
v1.0.1
v1.0.0
v0.1.4
v0.1.3
v0.1.2
v0.1.1
v0.0.3
v0.0.2
v0.0.1
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
andeerc/kurama#14
Reference in a new issue
andeerc/kurama
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?