From: Junio C Hamano <gitster@pobox.com>
To: Roman Fietze <roman.fietze@telemotive.de>
Cc: "Shawn O. Pearce" <spearce@spearce.org>, git@vger.kernel.org
Subject: Re: [PATCH] bash completion: add space between branch name and status flags
Date: Fri, 20 Nov 2009 09:53:28 -0800 [thread overview]
Message-ID: <7v4oopxeuf.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <200911201309.16193.roman.fietze@telemotive.de> (Roman Fietze's message of "Fri\, 20 Nov 2009 13\:09\:16 +0100")
Roman Fietze <roman.fietze@telemotive.de> writes:
> Hello Shawn, hello git list members,
>
> Wouldn't it improve the readability of the bash prompt, if there would
> be a space between the branch name and the status flags (dirty, stash,
> untracked)?
Perhaps.
> Signed-off-by: Roman Fietze <roman.fietze@telemotive.de>
> ---
> contrib/completion/git-completion.bash | 6 ++++--
> 1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-
> completion.bash
> index bd66639..407176b 100755
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -169,10 +169,12 @@ __git_ps1 ()
> fi
> fi
>
> + local f="$w$i$s$u$r"
I think this line and the two changes to printf below is a big improvement
(unless we are using f for something else---I didn't look). But I think
the next line is wrong.
> + f=${f:+ $f}
The $r string is designed to be used as suffix from the beginning and
always has "|" in front of it as a delimiter, so if there is no w/i/s/u
(and I suspect many people do not use GIT_PS1_SHOWDIRTYSTATE and friends,
and these are _always_ empty for them) the above will begin with "|".
There is no need to steal one column from a typeable width from the
command line in such a case.
> if [ -n "${1-}" ]; then
> - printf "$1" "$c${b##refs/heads/}$w$i$s$u$r"
> + printf "$1" "$c${b##refs/heads/}$f"
> else
> - printf " (%s)" "$c${b##refs/heads/}$w$i$s$u$r"
> + printf " (%s)" "$c${b##refs/heads/}$f"
> fi
> fi
> }
To implement your stated goal (dirty/stash/untracked), you probably want
to do this instead...
local f="$w$i$s$u"
f="${f:+ $f}$r"
next prev parent reply other threads:[~2009-11-20 17:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-20 12:09 [PATCH] bash completion: add space between branch name and status flags Roman Fietze
2009-11-20 17:53 ` Junio C Hamano [this message]
2009-12-30 13:41 ` Nanako Shiraishi
2009-12-30 14:57 ` Shawn O. Pearce
2009-12-30 19:27 ` Junio C Hamano
2009-12-31 3:04 ` Shawn O. Pearce
2010-01-06 11:59 ` Roman Fietze
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=7v4oopxeuf.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=roman.fietze@telemotive.de \
--cc=spearce@spearce.org \
/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).