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

Re: git-PS1 bash prompt setting

From
Sean <seanlkml@sympatico.ca>
Date
Nov 27, 2006, 17:38 UTC
Message-ID
<BAYC1-PASMTP0709A31FDE4B0DBA4174E9AEE60@CEZ.ICE>
In-Reply-To
<20061127170249.GC6616@spearce.org>

On Mon, 27 Nov 2006 12:02:49 -0500 Shawn Pearce <spearce@spearce.org> wrote:

Show 6 quoted lines
> When I originally coded the first version of __git_ps1 I was using
> it on a Cygwin system, where the fork+exec of the external script
> can take a little while.  The time to fork+exec two programs (script
> and then git) is huge compared to just fork+exec of git by itself,
> so I coded it as a function.  On the other hand my Mac OS X system
> doesn't even blink at either implementation.

For sure, that's probably the reason that it was suggested to be included as a built-in, it would reduce the overhead.

Show 7 quoted lines
> I'm not sure that's worth implementing in the core code.
> Most shells that will let you invoke a command as part of their
> prompt generation will also let you use builtin functions and do
> some basic string manipulation (e.g. like I do above with bash).
> At which point it is say 5 lines of shell (nicely formatted) to
> craft a prompt string vs. 15-20 lines of C to parse the option,
> read HEAD, and craft a prompt string.
Well, as per my previous message, it might be a little more worthwhile
if it did things like parse an additional format string which let
you reference config variables and relative directory etc.
It would give a lot of flexibility as to what someone wanted to
use as their PS1 when inside a git repo.
 
> If someone else contributes a --show-ps1 option that is useable as
> a replacement for my __git_ps1 I'll gladly jump on board and change
> to using it, but I just don't see a reason to write it myself.

Yeah.. __git_ps1 could just call "git --show-ps1" if it ever comes into existence ;o)

Previous: Shawn Pearce
Message 13 of 13 in “git-PS1 bash prompt setting”
  1. SeanNov 16, 2006
  2. Junio C HamanoNov 16, 2006
  3. Johannes SchindelinNov 26, 2006
  4. SeanNov 26, 2006
  5. Johannes SchindelinNov 26, 2006
  6. Nicolas VilzNov 26, 2006
  7. Junio C HamanoNov 27, 2006
  8. Nicolas VilzNov 27, 2006
  9. Shawn PearceNov 27, 2006
  10. Jakub NarebskiNov 27, 2006
  11. SeanNov 27, 2006
  12. Shawn PearceNov 27, 2006
  13. SeanNov 27, 2006

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.