threads / patch / 39588

patchgit-prompt.sh: Document GIT_PS1_STATESEPARATOR

Subject: [PATCH] git-prompt.sh: Document GIT_PS1_STATESEPARATOR

## tl;dr

3 messages between Jun 10, 2015 and Jun 16, 2015. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Joe Cridge· Jun 10, 2015, 17:19 UTC · lore

The environment variable GIT_PS1_STATESEPARATOR can be used to set the separator between the branch name and the state symbols in the prompt.

At present the variable is not mentioned in the inline documentation which makes it difficult for the casual user to identify.

Signed-off-by: Joe Cridge <joe.cridge@me.com>
---
 contrib/completion/git-prompt.sh | 4 ++++
 1 file changed, 4 insertions(+)
Show changes to contrib/completion/git-prompt.sh +4 −0
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index f18aedc..366f0bc 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -66,6 +66,10 @@
 #     git           always compare HEAD to @{upstream}
 #     svn           always compare HEAD to your SVN upstream
 #
+# You can change the separator between the branch name and the above
+# state symbols by setting GIT_PS1_STATESEPARATOR. The default separator
+# is SP.
+#
 # By default, __git_ps1 will compare HEAD to your SVN upstream if it can
 # find one, or @{upstream} otherwise.  Once you have set
 # GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by
-- 
2.4.2
SZEDER Gábor· Jun 16, 2015, 13:32 UTC · re: Joe Cridge · lore

Re: [PATCH] git-prompt.sh: Document GIT_PS1_STATESEPARATOR

Quoting Joe Cridge <joe.cridge@me.com>:
Show 5 quoted lines
> The environment variable GIT_PS1_STATESEPARATOR can be used to set the
> separator between the branch name and the state symbols in the prompt.
>
> At present the variable is not mentioned in the inline documentation which
> makes it difficult for the casual user to identify.
Thanks, makes sense.
Show 17 quoted lines
> Signed-off-by: Joe Cridge <joe.cridge@me.com>
> ---
>  contrib/completion/git-prompt.sh | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/contrib/completion/git-prompt.sh  
> b/contrib/completion/git-prompt.sh
> index f18aedc..366f0bc 100644
> --- a/contrib/completion/git-prompt.sh
> +++ b/contrib/completion/git-prompt.sh
> @@ -66,6 +66,10 @@
>  #     git           always compare HEAD to @{upstream}
>  #     svn           always compare HEAD to your SVN upstream
>  #
> +# You can change the separator between the branch name and the above
> +# state symbols by setting GIT_PS1_STATESEPARATOR. The default separator
> +# is SP.

This is not a specification of a protocol or file or input/output format, where we formally use SP and LF. Perhaps we could spell out SP as a space here, for the sake of the "casual user"?

Show 6 quoted lines
> +#
>  # By default, __git_ps1 will compare HEAD to your SVN upstream if it can
>  # find one, or @{upstream} otherwise.  Once you have set
>  # GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by
> --
> 2.4.2
Joe Cridge· Jun 16, 2015, 14:27 UTC · re: SZEDER Gábor · lore

Re: [PATCH] git-prompt.sh: Document GIT_PS1_STATESEPARATOR

Quoting SZEDER Gábor <szeder@ira.uka.de>:
Show 13 quoted lines
>> diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
>> index f18aedc..366f0bc 100644
>> --- a/contrib/completion/git-prompt.sh
>> +++ b/contrib/completion/git-prompt.sh
>> @@ -66,6 +66,10 @@
>> #     git           always compare HEAD to @{upstream}
>> #     svn           always compare HEAD to your SVN upstream
>> #
>> +# You can change the separator between the branch name and the above
>> +# state symbols by setting GIT_PS1_STATESEPARATOR. The default separator
>> +# is SP.
> 
> This is not a specification of a protocol or file or input/output format, where we formally use SP and LF.  Perhaps we could spell out SP as a space here, for the sake of the "casual user"?
Yes, I agree. Would it also be worth changing lines 25 and 29?

@@ 18,12 @@ # 3b) Alternatively, for a slightly faster prompt, __git_ps1 can # be used for PROMPT_COMMAND in Bash or for precmd() in Zsh # with two parameters, <pre> and <post>, which are strings # you would put in $PS1 before and after the status string # generated by the git-prompt machinery. e.g. # Bash: PROMPT_COMMAND='__git_ps1 "\u@\h:\w" "\\\$ "' # will show username, at-sign, host, colon, cwd, then # various status string, followed by dollar and SP, as # your prompt. # ZSH: precmd () { __git_ps1 "%n" ":%~$ " "|%s" } # will show username, pipe, then various status string, # followed by colon, cwd, dollar and SP, as your prompt.

← back to recent threads