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

Re: [StGIT PATCH] Bash snippet to show branch and patch in bash prompt

From
Robin Rosenberg <robin.rosenberg@dewire.com>
Date
Oct 30, 2006, 10:32 UTC
Message-ID
<200610301132.45086.robin.rosenberg@dewire.com>
In-Reply-To
<4545CC6F.90001@tromer.org>
måndag 30 oktober 2006 10:57 skrev Eran Tromer:
> That's an annoying 430ms delay at every prompt, on my box. Does StGIT do
> something expensive on every invocation?

I don't type fast enough to notice really and my machine seems faster, ~300 ms per prompt.

Show 15 quoted lines
>
> Ben Clifford'd solution is pretty much instantaneous, and the following
> extends it to StGIT (in a less clean but much faster way):
>
> ----------------------------------------------
> __prompt_githead() {
>     __PS_GIT="$(git-symbolic-ref HEAD 2>/dev/null)" || exit
>     __PS_GIT="$(basename $__PS_GIT)"
>     echo -n " $__PS_GIT"
>     __PS_GIT=$(cat "${GIT_DIR:-.git}/patches/$__PS_GIT/current" \
>                2>/dev/null) || exit
>     echo -n ":$__PS_GIT"
> }
> PS1='[\u@\h \W$(__prompt_githead)]\$ '
> ----------------------------------------------

This doesn't work if the branch have a / in the name or if you are in a subdirectory, not the top level. Probably not hard to fix though.

Previous: Catalin MarinasNext: Robin Rosenberg
Message 4 of 7 in “Bash snippet to show branch and patch in bash prompt”
  1. Bash snippet to show branch and patch in bash promptRobin Rosenberg, Oct 29, 2006
  2. Eran TromerOct 30, 2006
  3. Catalin MarinasOct 30, 2006
  4. Robin RosenbergOct 30, 2006
  5. Bash snippet to show branch and patch in bash promptRobin Rosenberg, Oct 30, 2006
  6. Eran TromerOct 30, 2006
  7. Catalin MarinasNov 2, 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.