dev_info
is a simple command line utility that can display informations related to the current
git directory. Contrary to other alternatives, it is quite fast because it relies on libgit2
to directly obtain repository information without spawning other processes.
First run:
cargo install dev_info
Then add it to your PROMPT
or PS1
(this depends on your shell). For zsh
I have the
following:
setopt PROMPT_SUBST
PROMPT='[%{%F{red}%}%n%{%f%}@%{%F{red}%}%m%{%f%}]%{%F{blue}%}%~%{%f%} $(dev_info -b -c 7 -s) %# '
For bash
you can look there: https://wiki.archlinux.org/index.php/Bash/Prompt_customization#Embedding_commands
Currently the available options are limited:
Usage: dev_info [options]
Options:
-h, --help print this help menu
-C, --color SCHEME render using a color scheme
-b, --branch print the branch name
-c, --commit LENGTH print the commit id, truncated to LENGTH
-s, --state print the repository state
Right now the colorized output creates cursor position reset bugs, I have to figure out how to escape the ANSI sequences.