Skip to content

akiomik/git-branch-status

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-branch-status

A command line tool for displaying git branch colored by status, like zsh's vcs_info.

screenshot

Installation

git clone https://github.com/akiomik/git-branch-status.git && cd git-branch-status
cargo build --release
cp target/release/git-branch-status ~/bin

Usage

Zsh

Add the following to ~/.zshrc:

# ~/.zshrc
setopt prompt_subst
RPROMPT='$(git branch-status --mode zsh)'

Zsh with Starship 🚀

Add the following to ~/.config/starship.toml:

format = """
$directory\
$custom\
$line_break\
$character"""

[custom.branchstatus]
command = "git branch-status --mode zsh"
when = "[[ -d .git ]] || [[ `git rev-parse --git-dir > /dev/null 2>&1; echo $?` -eq 0 ]]"
format = " on $output"

Benchmark

Run ./scripts/bench.sh. git-branch-status is about 5x faster than vcs_info on M1 MacBook Pro (2021).

❯ ./scripts/bench.sh
Setup vcs_info...done!
Setup git-branch-status...done!

Run 'vcs_info; echo $vcs_info_msg_0_' 100 times
....................................................................................................done!
Elapsed time: 2029ms

Run './target/release/git-branch-status --mode zsh' 100 times
....................................................................................................done!
Elapsed time: 404ms