Skip to content

Bhacaz/branch-select

Repository files navigation

branch-select

Interactive git branch selector with fuzzy search, built with Go and Bubbletea TUI.

A modern replacement for fzf-based branch selection scripts, compiled as a single binary with no external dependencies.

Features

  • Interactive branch selection with fuzzy search
  • Branches sorted by last commit date (most recent first)
  • Live git log preview for selected branch
  • Highlights current branch
  • Keyboard navigation (arrow keys)
  • No external dependencies (unlike fzf-based solutions)
  • Single static binary

Installation

NPM (Recommended)

Install via NPM with Bun (automatically downloads the correct binary for your platform):

# Using bun (recommended)
bun install -g branch-select

# Or with npm
npm install -g branch-select

# Or with yarn
yarn global add branch-select

Supported platforms:

  • macOS (Intel and Apple Silicon)
  • Linux (x64 and ARM64)

Download Binary

Download the latest release from the releases page, or build from source:

Build from Source

go build -ldflags="-s -w" -o branch-select

For smaller binary size:

# Install upx (optional)
# brew install upx  # macOS
# apt-get install upx  # Linux

go build -ldflags="-s -w" -o branch-select
upx --best --lzma branch-select

Install to PATH

# Copy to a directory in your PATH
cp branch-select ~/.local/bin/

# Or use go install
go install github.com/bhacaz/branch-select@latest

Setup Git Alias

Add to your ~/.gitconfig:

[alias]
    bs = !branch-select

Usage

Run directly:

./branch-select

Or use the git alias:

git bs

Keyboard Controls

  • / - Navigate branches
  • Enter - Checkout selected branch
  • Esc or Ctrl+C - Cancel and exit
  • Type any letter to search/filter branches (fuzzy search)
  • Backspace - Delete search character

How It Works

The application:

  1. Fetches all local git branches sorted by commit date
  2. Displays them in an interactive TUI with fuzzy search
  3. Shows a live preview of git log for the selected branch
  4. Checks out the selected branch when you press Enter

Comparison with fzf-based Script

Original bash script with fzf:

  • Requires fzf to be installed separately
  • Shell script with external dependencies
  • Works great but needs fzf in PATH

This Go implementation:

  • Single binary, no dependencies
  • Native TUI with Bubbletea
  • More portable across systems
  • Can be distributed as a single file

Requirements

  • Git (must be in PATH)
  • Must be run from within a git repository

Development

Prerequisites

This project uses mise to manage tool versions. Install mise first:

# Install mise
curl https://mise.run | sh

# Or with homebrew
brew install mise

Setup

# Clone repository
git clone https://github.com/bhacaz/branch-select.git
cd branch-select

# Install tools (Go and Bun) via mise
mise install

# Install dependencies
go mod download

# Run
go run main.go

# Build
go build -o branch-select

# Or use make
make build

Testing NPM Package Locally

# Pack the package
bun pack

# Install globally from local tarball
bun install -g ./branch-select-1.0.0.tgz

# Test
branch-select

License

MIT License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors