Skip to main content

A Git utility that shows recently checked-out branches in chronological order and lets you quickly switch between them.

Project description

lbranch

lbranch ("last branch") is a git utility that shows your recently checked out branches in chronological order, with an optional interactive checkout.

Usage

# Show last 5 branches (default)
lbranch
# Show last N branches
lbranch -n 3
lbranch --number 3
# Show branches and select one to checkout
lbranch -s
lbranch --select
# Show last N branches and select one
lbranch -n 3 -s
# Color control
lbranch --no-color     # Disable colored output
lbranch --force-color  # Force colored output even in non-TTY environments

Example Output

Last 5 branches:
1) feature/new-ui
2) main
3) bugfix/login
4) feature/api
5) develop

Color Support

lbranch automatically detects if your terminal supports colors:

  • Colors are disabled when output is not to a terminal (when piped to a file or another command)
  • Colors are disabled on Windows unless running in a modern terminal (Windows Terminal, VS Code, etc.)
  • You can force colors on with --force-color or off with --no-color
  • lbranch respects the NO_COLOR and FORCE_COLOR environment variables

Exit Codes

lbranch follows the standard exit codes from sysexits.h for better integration with scripts and other tools:

  • 0: Success
  • 64: Command line usage error (not in a git repository, invalid selection)
  • 66: Cannot open input (no branch history/no commits)
  • 69: Service unavailable (git command not found)
  • 75: Temporary failure (branch checkout failed, retry possible)
  • 130: Operation interrupted (Ctrl+C)

These follow Unix conventions where exit codes 64-78 are standardized error codes, and 128+N indicates termination by signal N.

Requirements

  • Python 3.7+
  • Git

Installation

Using pip

You can install lbranch directly from PyPI:

pip install lbranch

Using Homebrew

You can install lbranch using Homebrew:

brew tap dcchuck/lbranch
brew install lbranch

License

Distributed under the MIT License. See LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lbranch-0.1.2.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lbranch-0.1.2-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file lbranch-0.1.2.tar.gz.

File metadata

  • Download URL: lbranch-0.1.2.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for lbranch-0.1.2.tar.gz
Algorithm Hash digest
SHA256 cf7ea50c19751256e7f068be4a37d89deb32870ee0c64ff5b50ce12855030cce
MD5 43e441d4d575c6373cb784fa8fa6e4ea
BLAKE2b-256 234a5302faa15692ce1b2616c6156e31b3406a002ada4d938ea96423bd9f332d

See more details on using hashes here.

File details

Details for the file lbranch-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: lbranch-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for lbranch-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d73784b647f881f8fa98fab7e22cd245afc3b50cd6acb183719add7cde37355c
MD5 6c716c43dd96c89111881be0fd52d05a
BLAKE2b-256 12c10463994ffb26e44624792f6568ba03f69ba7311a416f79ade6f4829d3f09

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page