sh-vcprompt - VCS information in your prompt
sh-vcprompt is a pure POSIX Shell script that prints a short string to be included in your prompt, with barebones information about the current working directory for various version control systems. It is designed to be small and lightweight (its try) rather than comprehensive and works with all shells because was developed to be this.
Currently, it has varying degrees of recognition for Mercurial and Git. Others VCS like Fossil, Subversion and CVS, be added in the future versions.
Try checkout from the main repository hosted on Github.com:
git clone --branch master http://github.com/codigorama/sh-vcprompt.git cd sh-vcprompt
And type the following commands to install in system:
make sudo make install
For user install, try this:
make prefix=[path/to/your/scripts] make install
To use it with Bash, just call it in PS1:
PS1='\u@\h:\w $(shvcp)\$ '
To use it with zsh, you need to enable shell option PROMPT_SUBST, and then do similarly to bash:
setopt prompt_subst PROMPT='[%n@%m] [%~] $(shvcp)'
sh-vcprompt prints nothing if the current directory is not managed by a recognized VCS.
Show usage message and formats.
You can customize the output of sh-vcprompt using format strings, which can be specified either on the command line. For example:
Format strings use printf-like "%" escape sequences:
Version Control System - VCS name (e.g. git, hg).
Current branch name.
hash key of the latest commit.
Latest revision or the latest number of commit.
+to modifications (added, changed or removed files).
*to appendings (staged files).
?to untracked files.
The default format string is:
Which is notable because it works with every supported VCSs.
Written by Hallison Batista
Prigner is Copyright (C) 2012, Hallison Batista under MIT License
See LICENSE file for more information about license.