git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: "SZEDER Gábor" <szeder@ira.uka.de>
Cc: git@vger.kernel.org, Anders Kaseorg <andersk@MIT.EDU>,
	Danny Yates <mail4danny@googlemail.com>,
	Felipe Contreras <felipe.contreras@gmail.com>,
	Ted Pavlic <ted@tedpavlic.com>, Dan McGee <dan@archlinux.org>
Subject: Re: Where should git-prompt.sh be installed?
Date: Thu, 25 Oct 2012 09:12:50 -0700	[thread overview]
Message-ID: <20121025161250.GA30334@elie.Belkin> (raw)
In-Reply-To: <20121025151120.GA14740@goldbirke>

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

  reply	other threads:[~2012-10-25 16:13 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-22 20:46 [PATCH 0/2] completion: split into git-prompt.sh Felipe Contreras
2012-05-22 20:46 ` [PATCH 1/2] completion: remove executable mode Felipe Contreras
2012-05-22 20:46 ` [PATCH 2/2] completion: split __git_ps1 into a separate script Felipe Contreras
2012-05-22 21:07   ` Zbigniew Jędrzejewski-Szmek
2012-05-22 22:29     ` Ted Pavlic
2012-05-23 11:56       ` Felipe Contreras
2012-05-23 11:59     ` Felipe Contreras
2012-05-23 14:54     ` Junio C Hamano
2012-05-23 15:40       ` Felipe Contreras
2012-05-23 16:30         ` Junio C Hamano
2012-05-23 17:03         ` Ted Pavlic
2012-05-23 20:50           ` Felipe Contreras
2012-05-23 21:55             ` Ted Pavlic
2012-05-24 20:35               ` SZEDER Gábor
     [not found]                 ` <CAOnadRFbrhrFz7Ya3Vhgsju9G723Qu0OdJnM31xFmBqQNgj6gA@mail.gmail.com>
2012-05-25  7:35                   ` SZEDER Gábor
2012-05-25  7:50                     ` Thomas Rast
2012-05-25 10:01                       ` Felipe Contreras
2012-05-25 18:03                       ` Junio C Hamano
2012-05-24 20:49         ` SZEDER Gábor
2012-05-22 22:27   ` Ted Pavlic
2012-05-23 11:53     ` Felipe Contreras
2012-05-23 14:59       ` Junio C Hamano
2012-05-24 20:47   ` SZEDER Gábor
2012-05-25 17:51     ` Ville Skyttä
2012-10-25  0:51   ` Where should git-prompt.sh be installed? Jonathan Nieder
2012-10-25  1:59     ` Drew Northup
2012-10-25  6:02     ` Danny Yates
2012-10-25  7:45       ` [RFC/PATCH] __git_ps1: migrate out of contrib/completion Jonathan Nieder
2012-10-25 14:19         ` Felipe Contreras
2012-11-08 13:19         ` Todd Zullinger
2012-10-25  8:10       ` Where should git-prompt.sh be installed? Anders Kaseorg
2012-10-25 15:11     ` SZEDER Gábor
2012-10-25 16:12       ` Jonathan Nieder [this message]
2012-05-23 16:33 ` [PATCH 0/2] completion: split into git-prompt.sh Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121025161250.GA30334@elie.Belkin \
    --to=jrnieder@gmail.com \
    --cc=andersk@MIT.EDU \
    --cc=dan@archlinux.org \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=mail4danny@googlemail.com \
    --cc=szeder@ira.uka.de \
    --cc=ted@tedpavlic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).