Subject: Re: [PATCH] git-prompt.sh: Omit prompt for ignored directories

From: Richard Hansen <[email-masked]>
Date: Thu, 09 Oct 2014 18:09:15 -0400

On 2014-10-09 06:27, Jess Austin wrote:
> On Thu, Oct 9, 2014 at 12:37 AM, Richard Hansen <[email-masked]> wrote:
>> On 2014-10-08 17:37, Jess Austin wrote:
>>> On Wed, Oct 8, 2014 at 4:12 PM, Richard Hansen <[email-masked]> wrote:
>>>> On 2014-10-08 15:04, Jess Austin wrote:
>>>>> Introduce a new environmental variable, GIT_PS1_OMITIGNORED, which
>>>>> tells __git_ps1 to display nothing when the current directory is
>>>>> set (e.g. via .gitignore) to be ignored by git. In the absence of
>>>>> GIT_PS1_OMITIGNORED this change has no effect.
>>>>>
>>>>> Many people manage e.g. dotfiles in their home directory with git.
>>>>> This causes the prompt generated by __git_ps1 to refer to that "top
>>>>> level" repo while working in any descendant directory. That can be
>>>>> distracting, so this patch helps one shut off that noise.
...
>>
>> $ PS1='\n\w$(__git_ps1 " (%s)")\n\$ '
>>
>> /home/rhansen/projects (dotfiles)
>> $ GIT_PS1_OMITIGNORED=y
>>
>> /home/rhansen/projects              <-- Git prompt goes away as desired
>> $ cd foo
>>
>> /home/rhansen/projects/foo (master) <-- Git prompt back as expected
>> $ echo ignored/ >>.gitignore && mkdir -p ignored && cd ignored
>>
>> /home/rhansen/projects/foo/ignored  <-- I want the Git prompt here
>> $
>>
>> In other words:  If I were to use this feature, I'd want to be able to
>> hide the prompt when I'm in an ignored directory in my dotfiles work
>> tree, but show the prompt when I'm in an ignored directory in any other
>> work tree.
> 
> Would you want this configured in each repo (i.e. via a line in ".git/config"),
> or would you prefer something global so that it only need be set in one
> place? I'm not sure how the latter technique would work, so if that seems
> better please advise on how to go about that.

A 'git config' variable is fine.  The bash.showDirtyState,
bash.showUntrackedFiles, and bash.showUpstream config variables seem
like good examples to follow.

-Richard