Shell prompt for version control systems (git, hg, svn)
Here is an example of the prompt in gnome-terminal:
Only Ocaml's core. Installation on Ubuntu:
$ sudo add-apt-repository ppa:avsm/ppa
$ sudo apt-get update
$ sudo apt-get install ocaml opam
$ opam install core
$ git clone https://github.com/ekalinin/version-control-prompt.ml.git
$ cd version-control-prompt.ml
$ make
$ ls bin/
version-control-prompt
Copy binary in some constant path, for example ~/bin
:
$ mkdir -p ~/bin
$ cp bin/version-control-prompt ~/bin
For bash, add the follow in your ~/.bashrc
:
PURPLE2="\033[1;35m"
RESET="\033[m"
vc_prompt() {
local vc_prompt=$(~/bin/version-control-prompt)
if [ "$vc_prompt" != "" ]; then
echo -e "on $PURPLE2$vc_prompt$RESET"
fi
}
PS1='\u@\h:\w $(vc_prompt)\$ '
Default format string:
%type|%branch|%status %stats
You can override id like this:
# ...
vc_prompt() {
local vc_prompt=$(~/bin/version-control-prompt --fmt "(%type:%branch:%status)")
if [ "$vc_prompt" != "" ]; then
echo -e "on $PURPLE2$vc_prompt$RESET"
fi
}
# ...
MIT / LICENSE