git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 4/4] git-prompt.sh: add missing information in comments

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Jun 22, 2013, 13:40 UTC
Message-ID
<20130622134026.GM20052@goldbirke>
In-Reply-To
<8fcf64a70e63761f3982e1be05be0a2bb1fb68bf.1371780085.git.erdavila@gmail.com>
On Thu, Jun 20, 2013 at 11:25:29PM -0300, Eduardo R. D'Avila wrote:
Show 28 quoted lines
> Mention that the command below is needed for prompt
> in ZSH with PS1:
>   setopt PROMPT_SUBST
> 
> Make it clear that colored prompt is only available
> in PROMPT_COMMAND mode.
> 
> Signed-off-by: Eduardo R. D'Avila <erdavila@gmail.com>
> ---
> 5	4	contrib/completion/git-prompt.sh
>  contrib/completion/git-prompt.sh | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
> index 70515cc..3ab2a69 100644
> --- a/contrib/completion/git-prompt.sh
> +++ b/contrib/completion/git-prompt.sh
> @@ -13,10 +13,10 @@
>  #    3a) Change your PS1 to call __git_ps1 as
>  #        command-substitution:
>  #        Bash: PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
> -#        ZSH:  PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ '
> +#        ZSH:  setopt PROMPT_SUBST ; PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ '
>  #        the optional argument will be used as format string.
> -#    3b) Alternatively, if you are using bash, __git_ps1 can be
> -#        used for PROMPT_COMMAND with two parameters, <pre> and
> +#    3b) Alternatively, if you are using Bash or ZSH, __git_ps1 can
> +#        be used for PROMPT_COMMAND with two parameters, <pre> and

The git-prompt script only supports bash and zsh, so that "if you are using Bash or ZSH" part doesn't say much, does it? Furthermore, zsh doesn't have PROMPT_COMMAND but a similar facility. So how about something like this instead?

# 3b) Alternatively, __git_ps1 can be used for PROMPT_COMMAND in # Bash or for precmd in ZSH with two parameters, <pre> and

Show 10 quoted lines
>  #        <post>, which are strings you would put in $PS1 before
>  #        and after the status string generated by the git-prompt
>  #        machinery.  e.g.
> @@ -78,7 +78,8 @@
>  #
>  # If you would like a colored hint about the current dirty state, set
>  # GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
> -# the colored output of "git status -sb".
> +# the colored output of "git status -sb" and are available only when
> +# using __git_ps1 for PROMPT_COMMAND.
Likewise:
# using __git_ps1 for PROMPT_COMMAND or precmd.
Show 6 quoted lines
>  
>  # __gitdir accepts 0 or 1 arguments (i.e., location)
>  # returns location of .git repo
> -- 
> 1.8.3.1.487.g28387b2
> 
Previous: Eduardo R. D'Avila
Message 15 of 15 in “git-prompt: cleaning and improvement”
  1. 0/4 git-prompt: cleaning and improvementEduardo R. D'Avila, Jun 21, 2013
  2. 1/4 t9903: add tests for git-prompt pcmodeEduardo R. D'Avila, Jun 21, 2013
  3. SZEDER GáborJun 22, 2013
  4. Eduardo D'AvilaJun 22, 2013
  5. Junio C HamanoJun 23, 2013
  6. SZEDER GáborJun 24, 2013
  7. 2/4 git-prompt.sh: refactor colored prompt codeEduardo R. D'Avila, Jun 21, 2013
  8. Øystein WalleJun 22, 2013
  9. Eduardo D'AvilaJun 22, 2013
  10. SZEDER GáborJun 23, 2013
  11. Eduardo R. D'AvilaJun 25, 2013
  12. 3/4 git-prompt.sh: do not print duplicate clean color codeEduardo R. D'Avila, Jun 21, 2013
  13. SZEDER GáborJun 22, 2013
  14. 4/4 git-prompt.sh: add missing information in commentsEduardo R. D'Avila, Jun 21, 2013
  15. SZEDER GáborJun 22, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.