From: Junio C Hamano Date: Wed, 10 Oct 2012 23:00:59 GMT Subject: Re: [PATCH 1/2] Allow __git_ps1 to be used in PROMPT_COMMAND Message-ID: <7vlife9bkk.fsf@alter.siamese.dyndns.org> In-Reply-To: <20121010193158.GA6454@simaj.xs4all.nl> Simon Oosthoek writes: > __git_ps1 () > { > + local pcmode=no > + #defaults/examples: > + local ps1pc_start='\u@\h:\w ' > + local ps1pc_end='\$ ' > + local printf_format='(%s)' > + ... This conversion is wrong, given that ... > @@ -284,6 +317,12 @@ __git_ps1 () > fi > > local f="$w$i$s$u" > - printf -- "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p" ... the original has a SP in front. I've tentatively queued a fix-up patch on the topic branch before merging it to 'pu'. > + if [ $pcmode = yes ]; then > + PS1="$ps1pc_start(" > + PS1="$PS1$c${b##refs/heads/}${f:+ $f}$r$p" > + PS1="$PS1)$ps1pc_end" > + else > + printf -- "$printf_format" "$c${b##refs/heads/}${f:+ $f}$r$p" > + fi > fi > }