gbswitch
v1.0.2
Published
A CLI tool to quickly switch between recent git branches with an interactive TUI
Downloads
4
Maintainers
Readme
gbswitch
A simple and intuitive CLI tool to quickly switch between your recent Git branches using an interactive TUI.
Features
- Shows the 5 most recently committed-to branches
- Interactive terminal UI with arrow key navigation
- Displays relative time since last commit on each branch
- Automatically excludes the current branch from the list
- Handles uncommitted changes with stash option
- Color-coded output for better visibility
Installation
npm install -g gbswitchUsage
Simply run the command from any Git repository:
gbswitchHow it works:
- Run
gbswitchin any Git repository - The tool will display your 5 most recent branches (excluding current)
- Use ↑/↓ arrow keys to navigate through the list
- Press Enter to checkout the selected branch
- Press Esc or select "Cancel" to exit without switching
Features:
- Automatic stashing: If you have uncommitted changes, the tool will prompt you to stash them before switching
- Time display: Shows how long ago each branch was last committed to
- Current branch display: Shows your current branch at the top for reference
Shell Aliases
Add a shorter alias for quick access:
Bash
Add to ~/.bashrc:
alias gb="gbswitch"Zsh
Add to ~/.zshrc:
alias gb="gbswitch"Fish
Run once or add to ~/.config/fish/config.fish:
alias gb="gbswitch"Or create a persistent abbreviation:
abbr -a gb gbswitchPowerShell
Add to your PowerShell profile ($PROFILE):
Set-Alias -Name gb -Value gbswitchAfter adding the alias, restart your terminal or reload your config:
# Bash/Zsh
source ~/.bashrc # or ~/.zshrc
# Fish
source ~/.config/fish/config.fishRequirements
- Node.js (v12 or higher)
- Git
License
MIT
