SZEDER Gábor wrote:
> On Wed, Oct 24, 2012 at 05:51:06PM -0700, Jonathan Nieder wrote:

>> 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.

That's an interesting point.  Here's my logic:

The prompt function was originally Bash-specific, but over time
it gained support for Zsh as well.  If we're lucky, some day it
might gain support for mksh.

Meanwhile something simple like "git-prompt" would sound too much
like a normal git command, I fear.

Shell language extensions used:

 * future standard: local variables
 * cosmetic: [[ and (( syntax in place of test and $(
 * cosmetic: for ((n=1; n <= n_stop; n++)) instead of a more explicit
   while loop
 * cosmetic: var+=value syntax
 * optimization: <<< syntax to iterate over lines in a variable
   instead of, for example, sed + eval
 * arrays: svn_remote, svn_upstream --- using plain variables would
   require some escaping.

So nothing fundamental, but since this is only useful in shells like
Bash that support command substitution in $PS1, it seems reasonable
to keep using the extensions until someone wants to use it with a
more limited shell.

In other words, the interface is still "this is a scriptlet you might
source in your Bourne-style shell to get a __git_ps1 function to use
in your prompt".  The implementation language just happens not to be
POSIX shell today.

Perhaps it should return early in shells other than bash and zsh to
help people keep their .shrc simple.  What do you think?

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

Mercurial has an hg-prompt extension that can be used by running "hg
prompt".
http://mercurial.selenic.com/wiki/PromptExtension

I haven't found one for Subversion.

Bazaar has contrib/bash/bzrbashprompt.sh.  It doesn't get installed.

Thanks,
Jonathan
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to