26.5 Gathering information from version control systems

In a lot of cases, it is nice to automatically retrieve information from version control systems (VCSs), such as subversion, CVS or git, to be able to provide it to the user; possibly in the user’s prompt. So that you can instantly tell which branch you are currently on, for example.

In order to do that, you may use the vcs_info function.

The following VCSs are supported, showing the abbreviated name by which they are referred to within the system:

Bazaar (bzr)

https://bazaar.canonical.com/

Codeville (cdv)

http://freecode.com/projects/codeville/

Concurrent Versioning System (cvs)

https://www.nongnu.org/cvs/

Darcs (darcs)

http://darcs.net/

Fossil (fossil)

https://fossil-scm.org/

Git (git)

https://git-scm.com/

GNU arch (tla)

https://www.gnu.org/software/gnu-arch/

Mercurial (hg)

https://www.mercurial-scm.org/

Monotone (mtn)

https://monotone.ca/

Perforce (p4)

https://www.perforce.com/

Subversion (svn)

https://subversion.apache.org/

SVK (svk)

https://svk.bestpractical.com/

There is also support for the patch management system quilt (https://savannah.nongnu.org/projects/quilt). See Quilt Support below for details.

To load vcs_info:

autoload -Uz vcs_info

It can be used in any existing prompt, because it does not require any specific $psvar entries to be available.