Subject: Re: Where should git-prompt.sh be installed?

From: SZEDER Gábor <[email-masked]>
Date: Thu, 25 Oct 2012 17:11:20 +0200

On Wed, Oct 24, 2012 at 05:51:06PM -0700, Jonathan Nieder wrote:
> Hi,
> 
> In olden days the admin would copy contrib/completion/git-completion.sh
> to
> 
>         /etc/bash_completion.d/git
> 
> and mortals could source /etc/bash_completion or
> /etc/bash_completion.d/git in their ~/.bashrc (possibly shared among
> multiple machines) so that the bash completion and __git_ps1 helpers
> could work.

Ah, the good old days!  I even modified 'make install' to copy the
completion script to /etc/bash_completion.d/.  And I was happy.

> With Git 1.7.12 __git_ps1 has been split into a separate file, to help
> users who only want __git_ps1 to avoid the overhead of loading the
> entire completion script (and allow the completion script to be loaded
> by bash-completion magic on the fly!).  Now the sysadmin should copy
> contrib/completion/git-completion.sh to
> 
> 	/usr/share/bash-completion/completions/git
> 
> and contrib/completion/git-prompt.sh to
> 
> 	/usr/share/git-core/contrib/?? (somewhere?)
> 
> Mortals source /etc/bash_completion in their ~/.bashrc (possibly
> shared among multiple machines) and expect bash completion to work.
> For __git_ps1, users should source that ?? path.
> 
> Questions:
> 
>  1) what path is appropriate for ?? above?
>  2) is this documented anywhere?

Don't know what is appropriate, and it's not documented.  I for one
copy it manually to ~/.git-prompt.sh every once in a while.  And I'm
not all that happy with that.

> Possible answers:
> 
>  1) Fedora uses /etc/profile.d/git-prompt.sh.  Gentoo uses
>     /usr/share/bash-completion/git-prompt.  Maybe others use
>     some other path.
> 
>  2) The scripts themselves suggest copying to ~/.git-completion.sh
>     and ~/.git-prompt.sh.
> 
> Proposal:
> 
>   1) /usr/lib/git-core/git-sh-prompt
>   2) git-sh-prompt(1)

Not sure about the "sh" part.  The prompt function is very
Bash-specific, it won't work under a plain POSIX shell.

Do other VCSes have similar prompt scripts?  Where do they install
theirs?

Gábor