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

Re: [PATCH 4/10] Add current branch in PS1 support to git-completion.bash.

From
Sean <seanlkml@sympatico.ca>
Date
Nov 27, 2006, 17:26 UTC
Message-ID
<BAYC1-PASMTP109DA8BB360DD64E76B7B0AEE60@CEZ.ICE>
In-Reply-To
<20061127165122.GB6616@spearce.org>

On Mon, 27 Nov 2006 11:51:23 -0500 Shawn Pearce <spearce@spearce.org> wrote:

Show 8 quoted lines
> I actually started with the name __git_current_branch but changed
> my mind on that and went with __git_ps1.
> 
> My rationale at the time was probably not correct (it was early this
> morning) but I figured that the current branch name is "master"
> while __git_ps1 prints " (master)".  Therefore __git_ps1 is not
> really printing the current branch, its printing the current branch
> and other stuff.  So I went with a name which implied its purpose.

Ahh, I had missed that, it makes some sense. Although it goes a bit against the commit message that the user is free to construct whatever PS1 format they like (ie. they're stuck with parenthesis around the branch name).

Just thinking out loud, what about allowing __git_ps1 to take a format string of its own? It could parse options like "(\b)" to mean git branch surrounded by parenthesis. But you could also do "[\b]" or "!\b" if you preferred.

Then adding additional options would be easy, like "\r" for repo relative path etc... and the user really could create just about any git prompt they wanted. Of course, if __git_ps1 sees it's not in a git directory, it would always return an empty string.

But that's maybe all too complicated to be worthwhile. It's something that could be considered for the git --show-ps1 option though.

Previous: Shawn PearceNext: Shawn Pearce
Message 17 of 19 in “Hide plumbing/transport commands from bash completion.”
  1. 2/10 Hide plumbing/transport commands from bash completion.Shawn O. Pearce, Nov 27, 2006
  2. 3/10 Teach bash how to complete options for git-name-rev.Shawn O. Pearce, Nov 27, 2006
  3. 4/10 Add current branch in PS1 support to git-completion.bash.Shawn O. Pearce, Nov 27, 2006
  4. SeanNov 27, 2006
  5. 5/10 Teach bash how to complete git-format-patch.Shawn O. Pearce, Nov 27, 2006
  6. Jakub NarebskiNov 27, 2006
  7. 6/10 Teach bash how to complete git-cherry-pick.Shawn O. Pearce, Nov 27, 2006
  8. 7/10 Teach bash how to complete git-rebase.Shawn O. Pearce, Nov 27, 2006
  9. 8/10 Teach bash about git log/show/whatchanged options.Shawn O. Pearce, Nov 27, 2006
  10. 9/10 Allow completion of --committer and --author arguments to git log.Shawn O. Pearce, Nov 27, 2006
  11. Nicolas VilzNov 27, 2006
  12. Shawn PearceNov 27, 2006
  13. Junio C HamanoNov 27, 2006
  14. Shawn PearceNov 27, 2006
  15. 10/10 Support bash completion of refs/remote.Shawn O. Pearce, Nov 27, 2006
  16. Shawn PearceNov 27, 2006
  17. SeanNov 27, 2006
  18. Shawn PearceNov 27, 2006
  19. SeanNov 27, 2006

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.