|
3 | 3 | # Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]>
|
4 | 4 | # Distributed under the GNU General Public License, version 2.0.
|
5 | 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 | 7 | #
|
8 | 8 | # To enable:
|
9 | 9 | #
|
|
13 | 13 | # 3a) Change your PS1 to call __git_ps1 as
|
14 | 14 | # command-substitution:
|
15 | 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 | 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 | 20 | # <post>, which are strings you would put in $PS1 before
|
21 | 21 | # and after the status string generated by the git-prompt
|
22 | 22 | # machinery. e.g.
|
23 | 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. |
24 | 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. |
28 | 30 | # Optionally, you can supply a third argument with a printf
|
29 | 31 | # format string to finetune the output of the branch status
|
30 | 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. |
34 | 37 | #
|
35 | 38 | # In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty value,
|
36 | 39 | # unstaged (*) and staged (+) changes will be shown next to the branch
|
|
78 | 81 | #
|
79 | 82 | # If you would like a colored hint about the current dirty state, set
|
80 | 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. |
82 | 86 |
|
83 | 87 | # __gitdir accepts 0 or 1 arguments (i.e., location)
|
84 | 88 | # returns location of .git repo
|
|
0 commit comments