view README.txt @ 189:f4e0e43ff7dd
Added tag 1.2 for changeset e0b3c95ad3c6
|author||Greg Ward <firstname.lastname@example.org>|
|date||Sun, 01 Dec 2013 21:42:39 -0500|
1 vcprompt: version control information in your prompt
4 vcprompt is a little C program that prints a short string with
5 barebones information about the current working directory for various
6 version control systems. You configure your shell to include the
7 output of vcprompt in your prompt, and you get version control
8 information in your prompt.
10 vcprompt is designed to be small and lightweight rather than
11 comprehensive. Currently, it has varying degrees of support for
12 Mercurial, Git, Subversion, CVS, and Fossil working copies.
14 vcprompt has minimal dependencies: it does as much as it can with the
15 standard C library and POSIX calls. It should work on any
16 POSIX-compliant system with a C99 compiler. Some optional features
17 require external libraries (see "Dependencies" below).
19 To build vcprompt from the source tarball:
24 If you're building in a source checkout, you also need GNU autoconf:
30 (vcprompt requires GNU make, so if you are using a BSD variant where
31 the default make is BSD make, you will need to install GNU make and
32 run "gmake".)
34 To install it in your home directory:
36 make install PREFIX=$HOME
38 To make life easier for packagers, the Makefile also supports DESTDIR:
40 make install DESTDIR=/tmp/packageroot PREFIX=/usr
42 Please report build failures to the development mailing list,
45 vcprompt includes a fairly comprehensive test suite. If you want to
46 run it, see "Testing" below.
52 vcprompt requires GNU make to build.
54 vcprompt requires GNU autoconf to build from a source checkout (but
55 not from a source tarball).
57 Support for Subversion >= 1.7 requires SQLite 3. If it's not present on
58 the build system, vcprompt will support Subversion <= 1.6. Either way,
59 the build should succeed and the tests should pass. To install the
60 required files:
62 sudo apt-get install libsqlite3-dev # Debian, Ubuntu
63 sudo yum install libsqlite3x-devel # Fedora, Red Hat
65 To see which features are built-in to your vcprompt binary, run
67 ./vcprompt -F
73 (For more details, see the man page.)
75 To use it with bash, just call it in PS1:
77 PS1='\u@\h $(vcprompt)\$ '
79 To use it with zsh, you need to enable shell option PROMPT_SUBST, and
80 then do similarly to bash:
82 setopt prompt_subst
83 PROMPT='[%n@%m] [%~] $(vcprompt)'
86 Format Strings
89 You can customize the output of vcprompt using format strings, which
90 can be specified either on the command line or in the VCPROMPT_FORMAT
91 environment variable. For example:
93 vcprompt -f "%b"
97 VCPROMPT_FORMAT="%b" vcprompt
99 are equivalent.
101 Format strings use printf-like "%" escape sequences:
103 %n name of the VC system managing the current directory
104 (e.g. "cvs", "hg", "git", "svn")
105 %b current branch name
106 %r current revision
107 %u ? if there are any unknown files
108 %m + if there are any uncommitted changes (added, modified, or
109 removed files)
110 %% a single % character
112 All other characters are expanded as-is.
114 (For more details, see the man page.)
120 To run vcprompt's test suite:
122 make check
124 Test failures should be loud and obvious. Please report any test
125 failures to the development mailing list:
129 To check for memory errors, you can run vcprompt's test suite under
132 make grind
134 Obviously, this requires that you have valgrind installed.
136 Testing multiple versions of the same tool
139 Subversion changes its working copy format every couple of years, so
140 vcprompt supports three formats: the pre-1.4 XML format, the 1.4..1.6
141 plain-text format, and the post-1.7 SQLite format. Actually testing
142 these requires that you have different versions of Subversion on hand,
143 each installed in a separate prefix.
145 For example, I keep multiple versions in /usr/local/subversion-1.x, so
146 I can test them like this:
148 rm -f tests/svn-repo*.tar && make check-svn TOOLPATH=/usr/local/subversion-1.6/bin
149 rm -f tests/svn-repo*.tar && make check-svn TOOLPATH=/usr/local/subversion-1.7/bin
151 Actually *building* multiple versions of Subversion is harder than you
152 would believe. (In fact, I've been unable to build anything older than
153 1.5, so vcprompt's support for pre-1.4 working copies is currently
156 TOOLPATH is supported for all tools; I also keep multiple versions of
157 Mercurial around, so I can test vcprompt against them:
159 rm -f tests/hg-repo.tar && make check-svn TOOLPATH=/usr/local/mercurial-2.4/bin
160 rm -f tests/hg-repo.tar && make check-svn TOOLPATH=/usr/local/mercurial-2.5/bin
167 Patches are welcome. Please follow these guidelines:
169 * Ensure that the tests pass before and after your patch. To run the
170 tests quickly:
172 make check
174 To run the tests using valgrind (detect memory leaks):
176 make grind
178 If you cannot run the tests on a POSIX-compliant system, that is a
179 bug: please let me know.
181 * If at all possible, add a test whenever you fix a bug or implement
182 a feature. If you can write a test that has no dependencies (e.g.
183 no need to execute "git" or "hg" or whatever), add it to
184 tests/test-simple. Otherwise, add it to the appropriate
185 VC-specific test script, e.g. tests/test-git if it needs to be
186 able to run git.
188 * Keep the dependencies minimal: preferably just C99 and POSIX. If
189 you need to run an external executable, make sure it makes sense:
190 e.g. it's OK to run "git" in a git working directory, but *only*
191 if we already know we are in a git working directory.
193 * Performance matters! I wrote vcprompt so that people wouldn't have
194 to spawn and initialize an entire Python or Perl interpreter every
195 time they get a new shell prompt. Using system() to turn around
196 and spawn external commands -- especially ones that involve a
197 relatively large runtime penalty like Python scripts -- misses the
198 point of vcprompt.
200 In fact, you'll find that vcprompt contains hacky little
201 reimplementations of select bits and pieces of Mercurial, git,
202 Subversion, and CVS precisely in order to avoid running external
203 commands. (And, in the case of Subversion, to avoid depending on a
204 large, complex library.)
206 * Stick with my coding style:
207 - 4 space indents
208 - no tabs
209 - curly braces on the same line *except* when defining a function
210 - C99 comments and variable declarations are OK, at least until
211 someone complains that their compiler cannot handle them
213 * Feel free to add yourself to the contributors list below. (If you
214 don't do it, I'll probably forget.)
217 Author Contact
220 vcprompt was written by Greg Ward <greg at gerg dot ca>.
222 The latest version is available from either of my public Mercurial
229 Other Contributors
232 In chronological order:
234 Daniel Serpell
235 Jannis Leidel
236 Yuya Nishihara
237 KOIE Hidetaka
238 Armin Ronacher
239 Jordi Fita
240 Gregg Lind
241 Jakob Kramer
242 Robson Roberto Souza Peixoto
244 Thanks to all!
247 Copyright & License
250 Copyright (C) 2009-2013, Gregory P. Ward and contributors.
252 This program is free software; you can redistribute it and/or modify
253 it under the terms of the GNU General Public License as published by
254 the Free Software Foundation; either version 2 of the License, or
255 (at your option) any later version.
257 This program is distributed in the hope that it will be useful,
258 but WITHOUT ANY WARRANTY; without even the implied warranty of
259 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
260 GNU General Public License for more details.
262 You should have received a copy of the GNU General Public License along
263 with this program; if not, write to the Free Software Foundation, Inc.,
264 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.