git-prompt.sh: add missing information in comments
Mention that the command below is needed for prompt in ZSH with PS1: setopt PROMPT_SUBST Rephrase some parts that mention only the "current branch name" being displayed in the prompt. Replace it by stating that the "repository status" is displayed. Make it clear that colored prompt is only available in PROMPT_COMMAND/precmd mode. With-suggestions-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Eduardo R. D'Avila <erdavila@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Eduardo R. D'Avila committed
Jun 26, 2013 at 00:05 UTC
cf4cac4cfc13326920bdbf3d51236e2065f5ba2f
1 file changed
+15
-11
contrib/completion/git-prompt.sh
+15
-11
@@ -3,7 +3,7 @@
3
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
4
# Distributed under the GNU General Public License, version 2.0.
5
#
6
-# This script allows you to see the current branch in your prompt.
6
+# This script allows you to see repository status in your prompt.
7
#
8
# To enable:
9
#
@@ -13,24 +13,27 @@
13
# 3a) Change your PS1 to call __git_ps1 as
14
# command-substitution:
15
# Bash: PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
16
-# ZSH: PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ '
16
+# ZSH: setopt PROMPT_SUBST ; PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ '
17
# the optional argument will be used as format string.
18
-# 3b) Alternatively, if you are using bash, __git_ps1 can be
19
-# used for PROMPT_COMMAND with two parameters, <pre> and
18
+# 3b) Alternatively, __git_ps1 can be used for PROMPT_COMMAND in
19
+# Bash or for precmd() in ZSH with two parameters, <pre> and
20
# <post>, which are strings you would put in $PS1 before
21
# and after the status string generated by the git-prompt
22
# machinery. e.g.
23
# Bash: PROMPT_COMMAND='__git_ps1 "\u@\h:\w" "\\\$ "'
24
+# will show username, at-sign, host, colon, cwd, then
25
+# various status string, followed by dollar and SP, as
26
+# your prompt.
27
# ZSH: precmd () { __git_ps1 "%n" ":%~$ " "|%s" }
25
-# will show username, at-sign, host, colon, cwd, then
26
-# various status string, followed by dollar and SP, as
27
-# your prompt.
28
+# will show username, pipe, then various status string,
29
+# followed by colon, cwd, dollar and SP, as your prompt.
30
# Optionally, you can supply a third argument with a printf
31
# format string to finetune the output of the branch status
32
#
31
-# The argument to __git_ps1 will be displayed only if you are currently
32
-# in a git repository. The %s token will be the name of the current
33
-# branch.
33
+# The repository status will be displayed only if you are currently in a
34
+# git repository. The %s token is the placeholder for the shown status.
35
+#
36
+# The prompt status always includes the current branch name.
37
#
38
# In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty value,
39
# unstaged (*) and staged (+) changes will be shown next to the branch
@@ -78,7 +81,8 @@
81
#
82
# If you would like a colored hint about the current dirty state, set
83
# GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
81
-# the colored output of "git status -sb".
84
+# the colored output of "git status -sb" and are available only when
85
+# using __git_ps1 for PROMPT_COMMAND or precmd.
86
87
# __gitdir accepts 0 or 1 arguments (i.e., location)
88
# returns location of .git repo