The mug branches command now supports interactive selection with shell visible.
$ mug branches
(shows beautiful branch list)
(shows interactive prompt)
Select a branch:
1 ● feature/test (current)
2 ○ main
3 ○ test2
Enter branch number or name (or press Enter to skip):You can:
- Type a number (1, 2, 3, etc.) to select by position
- Type a branch name (or part of it) to select by name
- Press Enter to skip (no branch switch)
$ mug branches
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Branches
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
● feature/awesome (current)
○ main
○ develop
Select a branch:
1 ● feature/awesome (current)
2 ○ main
3 ○ develop
Enter branch number or name (or press Enter to skip): 2
✓ success: Switched to branch: main
$ (shell prompt visible)$ mug branches
(... list ...)
Enter branch number or name (or press Enter to skip): develop
✓ success: Switched to branch: develop
$ (shell prompt visible)$ mug branches
(... list ...)
Enter branch number or name (or press Enter to skip): feat
✓ success: Switched to branch: feature/awesome
$ (shell prompt visible)$ mug branches
(... list ...)
Enter branch number or name (or press Enter to skip):
$ (shell prompt visible, no branch switch)✨ Shows all branches with Unicode symbols:
●bright green for current branch○cyan for other branches- Numbered list for easy selection
- Colored header
- By number - Type 1, 2, 3, etc.
- By name - Type the full or partial branch name
- Skip - Just press Enter
- ✓ Shell prompt visible after command
- ✓ No screen clearing
- ✓ Inline prompt
- ✓ Works in normal shell workflow
- Exact matches
- Partial matches (substring)
- Case-sensitive matching
| Input | Result |
|---|---|
1 |
Switch to branch 1 |
main |
Switch to branch named "main" |
fea |
Switch to first branch containing "fea" |
| (empty) | Skip, no switch |
999 |
Error: Invalid number |
nonexistent |
Error: Branch not found |
Select a branch:
1 ● feature/awesome (current)
2 ○ main
3 ○ develop
Enter branch number or name (or press Enter to skip):
✓ success: Switched to branch: main
⚠ warning: Already on this branch
✘ error: Failed to switch: <reason>
$ git status
(on main)
$ mug branches
(shows branches with interactive prompt)
2
(switch to develop)
✓ success: Switched to branch: develop
$ pwd
/home/user/project
$ mug status
(shows status for develop branch)$ mug branches
(quick lookup and switch)- No complex keyboard navigation
- Just type and press Enter
- Works like familiar terminal tools
- Shell visible and ready for next command
BranchSelectorstructprompt_user()method for display and inputselect_branch_interactive()function
- Simple stdin/stdout based input
- No raw mode or terminal manipulation
- Graceful error handling
- Clean code
The Commands::Branches handler:
- Shows beautiful branch list (formatter)
- Prompts for interactive selection
- Switches branch if selected
- Shows result (success/warning/error)
✅ Simple - Type number or name ✅ Visual - See all branches numbered ✅ Familiar - Like terminal menus ✅ Fast - No navigation keys needed ✅ Safe - Can skip with Enter ✅ Shell-friendly - Prompt visible after ✅ Works everywhere - No special terminal features needed
- One selection per command (press Enter to go back to shell)
- No multi-select
- No branch filtering/search (but partial name matching helps)
Could add:
- Branch search/filter
- Show branch metadata
- Sort branches differently
- Delete branches from menu
- Create new branch from menu
Works on:
- ✓ All shells (bash, zsh, fish, etc.)
- ✓ All operating systems (Linux, macOS, Windows)
- ✓ SSH sessions
- ✓ Piped input (for scripts)
- ✓ CI/CD pipelines
Tested with:
- ✓ Selection by number
- ✓ Selection by full name
- ✓ Selection by partial name
- ✓ Skip (empty input)
- ✓ Invalid number
- ✓ Non-existent branch
- ✓ Already on selected branch
The interactive branch selector:
- 🎨 Shows beautiful numbered list
- 📝 Prompts for selection
- ✓ Switches on Enter
- 🚀 Returns to shell immediately
- 💡 Works like familiar terminal menus
Perfect for quick branch switching while keeping your shell workflow intact!