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