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

Re: git-PS1 bash prompt setting

From
Nicolas Vilz <niv@iaglans.de>
Date
Nov 17, 2006, 08:38 UTC
Message-ID
<20061117083801.GB11468@fry.bender.fht>
In-Reply-To
<20061116130111.921396df.seanlkml@sympatico.ca>
On Thu, Nov 16, 2006 at 01:01:11PM -0500, Sean wrote:
Show 18 quoted lines
> [branch!repo/relative/path]$ 
> 
> Where "repo" is the basename of the path to the root of your repo.
> An example would look like this:
> 
> [master!linus-2.6/Documentation/vm]$ 
> 
> Cheers,
> Sean
> 
> 
> #!/bin/bash
> BR=$(git symbolic-ref HEAD 2>/dev/null) || { echo "$@" ; exit ; }
> BR=${BR#refs/heads/}
> REL=$(git rev-parse --show-prefix) 
> REL="${REL//%\/}"
> LOC="${PWD%/$REL}"
> echo "[$BR!${LOC/*\/}${REL:+/$REL}]$ "
Just a note:

this doesn't work with bash 3.2. I think they altered the way of trimming variables in this version.

on systems with bash 3.2 installed, i get [master!linus-2.6/vm/vm]$ with the example above.

on systems with bash 3.1, it works properly.

unfortunatelly, i am not so good in bash scripting, so it will take some time for me to fix it.

Sincerly
Next: Sean
Message 1 of 4 in “Re: git-PS1 bash prompt setting”
  1. Nicolas VilzNov 17, 2006
  2. SeanNov 17, 2006
  3. Junio C HamanoNov 19, 2006
  4. Nicolas VilzNov 17, 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.