A command line tool for displaying git branch colored by status, like zsh's vcs_info.
git clone https://github.com/akiomik/git-branch-status.git && cd git-branch-status
cargo build --release
cp target/release/git-branch-status ~/bin
Add the following to ~/.zshrc
:
# ~/.zshrc
setopt prompt_subst
RPROMPT='$(git branch-status --mode zsh)'
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"
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