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

Re: git-PS1 bash prompt setting

From
Jakub Narebski <jnareb@gmail.com>
Date
Nov 27, 2006, 07:49 UTC
Message-ID
<eke571$ng2$1@sea.gmane.org>
In-Reply-To
<20061127065400.GA19174@spearce.org>
Shawn Pearce wrote:
Show 21 quoted lines
> Sean <seanlkml@sympatico.ca> wrote:
>> On Sun, 26 Nov 2006 15:27:07 +0100 (CET)
>> Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
>> 
>>> But there really is no good place to put it: most commands need a git 
>>> repository, and those which do not, are inappropriate to put an option 
>>> "--show-ps1" into. Except maybe repo-config. Thoughts?
>> 
>> What about just making it an option to the git wrapper?
> 
> I'm using something like this, and will be adding it to
> git-completion.bash tonight:
> 
>       __git_ps1 ()
>       {
>               local b="$(git symbolic-ref HEAD 2>/dev/null)"
>               if [ -n "$b" ]; then echo "(${b##refs/heads/})"; fi
>       }
>       PS1='[\u@\h \W$(__git_ps1)]\$ '
> 
> it works very well...

Perhaps, as it was proposed somewhere else in this thread, instead of \u@\h use $(git repo-config --get user.email)?

And I would add \!: at the beginning of prompt, but that might be just me.

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
Previous: Shawn PearceNext: Sean
Message 10 of 13 in “git-PS1 bash prompt setting”
  1. SeanNov 16, 2006
  2. Junio C HamanoNov 16, 2006
  3. Johannes SchindelinNov 26, 2006
  4. SeanNov 26, 2006
  5. Johannes SchindelinNov 26, 2006
  6. Nicolas VilzNov 26, 2006
  7. Junio C HamanoNov 27, 2006
  8. Nicolas VilzNov 27, 2006
  9. Shawn PearceNov 27, 2006
  10. Jakub NarebskiNov 27, 2006
  11. SeanNov 27, 2006
  12. Shawn PearceNov 27, 2006
  13. 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.