From: Jeff King <peff@peff.net>
To: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: Thomas Rast <trast@inf.ethz.ch>,
Junio C Hamano <gitster@pobox.com>,
Git List <git@vger.kernel.org>
Subject: Re: [PATCH 1/6] prompt: don't scream continuation state
Date: Mon, 3 Jun 2013 17:15:56 -0400 [thread overview]
Message-ID: <20130603211556.GB23224@sigill.intra.peff.net> (raw)
In-Reply-To: <CALkWK0=LzUe0k7rWcrbiiTZNOOGg+=SsQB3u2F2ysjb5AJ=qZw@mail.gmail.com>
On Mon, Jun 03, 2013 at 03:17:27PM +0530, Ramkumar Ramachandra wrote:
> Thomas Rast wrote:
> > Do you have other ways of distinguishing the branch and the state?
> > Colors? I'm a bit too lazy to check. Perhaps it could be made to only
> > use caps if not in colored mode?
>
> Currently, no. See git-prompt.sh:401, 403, 409; we don't have a
> separate color for $r. I didn't introduce a color in this series
> because it would conflict with rr/zsh-color-prompt which is in pu: we
> can introduce it after that graduates. I was thinking yellow, since
> that's not taken?
>
> You really should use colors. I don't think it's worth the extra
> ugliness to scream in the no-color case.
>
> As such, the prompt is a fine bikeshedding target. I even introduced
> GIT_PS1_SEPARATOR, because some people were unhappy with me stripping
> one whitespace (yes, one). If we go down the configurability road,
> we'll either end up with a ton of environment variables, or be made to
> write a generalized custom formatter which splices together tons of
> arguments using color (super painful). While I do agree that it is a
> matter of taste, we have to make a few compromises for the sake of
> sanity.
It seems silly to argue about output formats when we are writing a
prompt in a convenient Turing-complete scripting language already.
What about something like:
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index eaf5c36..1da3833 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -404,6 +404,8 @@ __git_ps1 ()
fi
gitstring=$(printf -- "$printf_format" "$gitstring")
PS1="$ps1pc_start$gitstring$ps1pc_end"
+ elif test "$(type -t __git_ps1_printer)" = "function"; then
+ __git_ps1_printer
else
# NO color option unless in PROMPT_COMMAND mode
printf -- "$printf_format" "$c${b##refs/heads/}${f:+ $f}$r$p"
and then you can define your own custom function if you like, which will
inherit all of the variables from __git_ps1. E.g.:
__git_ps1_printer() {
echo "${r,,}"
}
yields a lower-case "rebase-i". Of course there are many other variables
you want to put in your prompt, too. The only problem I see is that the
current set of variables is not suitable as a user-visible interface.
The names are not good (the branch should be "$branch" rather than "$b",
the operation-in-progress should be "$operation" or similar rather than
"$r", etc), and the formats are not as convenient ("$r" contains the
full "|REBASE-i 6/10", whereas it should be broken down so the printing
function can easily use a case statement).
And of course the variables would need documentation.
-Peff
next prev parent reply other threads:[~2013-06-03 21:16 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-02 14:03 [PATCH 0/6] Minor prompt, completion cleanups Ramkumar Ramachandra
2013-06-02 14:03 ` [PATCH 1/6] prompt: don't scream continuation state Ramkumar Ramachandra
2013-06-03 8:58 ` Thomas Rast
2013-06-03 9:47 ` Ramkumar Ramachandra
2013-06-03 21:15 ` Jeff King [this message]
2013-06-04 3:44 ` Ramkumar Ramachandra
2013-06-04 4:38 ` Jeff King
2013-06-04 5:59 ` Junio C Hamano
2013-06-03 17:23 ` Junio C Hamano
2013-06-02 14:03 ` [PATCH 2/6] completion: add common options for rev-parse Ramkumar Ramachandra
2013-06-07 15:33 ` Ramkumar Ramachandra
2013-06-02 14:03 ` [PATCH 3/6] completion: add common options for blame Ramkumar Ramachandra
2013-06-03 9:03 ` Thomas Rast
2013-06-03 9:32 ` Ramkumar Ramachandra
2013-06-03 18:07 ` SZEDER Gábor
2013-06-03 18:34 ` Junio C Hamano
2013-06-06 9:58 ` Peter Krefting
2013-06-03 17:24 ` Junio C Hamano
2013-06-02 14:03 ` [PATCH 4/6] completion: correct completion for format-patch Ramkumar Ramachandra
2013-06-02 17:20 ` Felipe Contreras
2013-06-02 17:29 ` Ramkumar Ramachandra
2013-06-02 14:03 ` [PATCH 5/6] completion: clarify difftool completion Ramkumar Ramachandra
2013-06-03 17:29 ` Junio C Hamano
2013-06-02 14:03 ` [PATCH 6/6] completion: clarify ls-tree, archive, show completion Ramkumar Ramachandra
2013-06-03 17:33 ` Junio C Hamano
2013-06-04 3:49 ` Ramkumar Ramachandra
2013-06-04 6:01 ` Junio C Hamano
2013-06-03 17:58 ` Junio C Hamano
2013-06-03 19:25 ` SZEDER Gábor
2013-06-07 17:21 ` Ramkumar Ramachandra
2013-06-07 18:36 ` Junio C Hamano
2013-06-07 18:45 ` SZEDER Gábor
2013-06-09 20:56 ` 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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130603211556.GB23224@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=artagnon@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=trast@inf.ethz.ch \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).