Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit cf4cac4

Browse files
erdavilagitster
authored andcommitted
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 <[email protected]> Signed-off-by: Eduardo R. D'Avila <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 15981f4 commit cf4cac4

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

contrib/completion/git-prompt.sh

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]>
44
# Distributed under the GNU General Public License, version 2.0.
55
#
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.
77
#
88
# To enable:
99
#
@@ -13,24 +13,27 @@
1313
# 3a) Change your PS1 to call __git_ps1 as
1414
# command-substitution:
1515
# 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)")]\$ '
1717
# 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
2020
# <post>, which are strings you would put in $PS1 before
2121
# and after the status string generated by the git-prompt
2222
# machinery. e.g.
2323
# 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.
2427
# 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.
2830
# Optionally, you can supply a third argument with a printf
2931
# format string to finetune the output of the branch status
3032
#
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.
3437
#
3538
# In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty value,
3639
# unstaged (*) and staged (+) changes will be shown next to the branch
@@ -78,7 +81,8 @@
7881
#
7982
# If you would like a colored hint about the current dirty state, set
8083
# 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.
8286

8387
# __gitdir accepts 0 or 1 arguments (i.e., location)
8488
# returns location of .git repo

0 commit comments

Comments
 (0)