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)