forked from djl/vcprompt
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
58 lines (35 loc) · 1.03 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
===========
vcprompt.py
===========
A pure-Python implementation of vcprompt_
.. _vcprompt: http://vc.gerg.ca/hg/vcprompt/
Installing
----------
Place ``vcprompt.py`` somewhere in your ``$PATH``, then add it to your prompt.
For bash::
PS1='\u@\h:\w $(vcprompt.py)\$'
For zsh you need to enable PROMPT_SUBST first::
setopt prompt_subst
PS1='[%n@%m] [%~] $(vcprompt.py)'
Requirements
------------
* Python 2.5+
Adding systems
--------------
To add a new VCS define a function which uses the 'vcs' decorator.
The function should take a single argument, the path to be checked for.
::
@vcs
def git(path):
file = os.path.join(path, '.git/HEAD')
if not os.path.exists(file):
return None
with open(file, 'r') as f:
line = f.read()
if re.match('^ref: refs/heads/', line):
return 'git:' + line.split('/')[-1]
TODO
----
- More complete support for CVS, Darcs and Fossil
- Add option to show state of repository
- Formatting for prompt string