git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jess Austin <jess.austin@gmail.com>
Date
Oct 9, 2014, 10:27 UTC
Message-ID
<CANp8Xb_kdpzYjWZxoWFtT+UWwMPpFD0znkoEKVpdukGf61Preg@mail.gmail.com>
In-Reply-To
<54361F30.8020603@bbn.com>
On Thu, Oct 9, 2014 at 12:37 AM, Richard Hansen <rhansen@bbn.com> wrote:
Show 44 quoted lines
> On 2014-10-08 17:37, Jess Austin wrote:
>> On Wed, Oct 8, 2014 at 4:12 PM, Richard Hansen <rhansen@bbn.com> 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.
>>>
>>> Interesting idea, though I would prefer this to be configurable on a
>>> per-repository basis.  (I wouldn't want to hide the prompt in any
>>> repository besides my home repository.)
>>
>> Sorry my description was unclear. Let's say you have a repo in "~",
>> and another in "~/projects/foo". Also, the file "~/.gitignore" has the line
>> "projects/" in it. In this case, you'd see repo info in your prompt while
>> in "~" or in "~/projects/foo", but not if you were in "~/projects". In that
>> sense, the prompt is not distracting you with the status of the top-level
>> repo when you're not looking at anything in that repo.
>
> I understand; I was concerned about this case:
>
> $ 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.

cheers, Jess

Previous: Richard HansenNext: Richard Hansen
Message 5 of 18 in “git-prompt.sh: Omit prompt for ignored directories”
  1. git-prompt.sh: Omit prompt for ignored directoriesJess Austin, Oct 8, 2014
  2. Richard HansenOct 8, 2014
  3. Fwd: [PATCH] git-prompt.sh: Omit prompt for ignored directoriesJess Austin, Oct 8, 2014
  4. Richard HansenOct 9, 2014
  5. Jess AustinOct 9, 2014
  6. Richard HansenOct 9, 2014
  7. git-prompt.sh: Hide prompt for ignored pwdJess Austin, Oct 14, 2014
  8. Johannes SixtOct 14, 2014
  9. Richard HansenOct 14, 2014
  10. Richard HansenOct 14, 2014
  11. git-prompt.sh: Option to hide prompt for ignored pwdJess Austin, Oct 15, 2014
  12. Richard HansenOct 15, 2014
  13. git-prompt.sh: Option to hide prompt for ignored pwdRichard Hansen, Jan 5, 2015
  14. Junio C HamanoJan 6, 2015
  15. 0/2 git-prompt.sh: Option to hide prompt for ignored pwdRichard Hansen, Jan 7, 2015
  16. 1/2 git-prompt.sh: if pc mode, immediately set PS1 to a plain promptRichard Hansen, Jan 7, 2015
  17. SZEDER GáborJan 14, 2015
  18. 2/2 git-prompt.sh: Option to hide prompt for ignored pwdRichard Hansen, Jan 7, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.