git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git-PS1 bash prompt setting
@ 2006-11-16 18:01 Sean
  2006-11-16 18:35 ` Junio C Hamano
  2006-11-26 14:27 ` Johannes Schindelin
  0 siblings, 2 replies; 17+ messages in thread
From: Sean @ 2006-11-16 18:01 UTC (permalink / raw)
  To: git; +Cc: Theodore Tso


Ted mentioned in the wart thread that having multiple branches per repo
means that the standard bash prompt isn't as much help as it could be.

For what it's worth i'll post a little script i've been using for quite
some time that helps a little.  It's called git-PS1 and is used by
including it in your bash PS1 variable like so:

export PS1='$(git-PS1 "[\u@\h \W]\$ ")'

If you're not in a git repo, the bash prompt you pass on the git-PS1
command line is used instead.  If you are in a git repo, you'll get
the following as a prompt:

[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}]$ "

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2006-11-27 17:38 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20061116130111.921396df.seanlkml@sympatico.ca>
2006-11-17  8:38 ` git-PS1 bash prompt setting Nicolas Vilz
2006-11-17  9:20   ` Sean
2006-11-19  6:28     ` Junio C Hamano
     [not found]   ` <20061117042051.d2fbddb6.seanlkml@sympatico.ca>
2006-11-17  9:52     ` Nicolas Vilz
2006-11-16 18:01 Sean
2006-11-16 18:35 ` Junio C Hamano
2006-11-26 14:27 ` Johannes Schindelin
2006-11-26 14:42   ` Sean
2006-11-26 15:18     ` Johannes Schindelin
     [not found]   ` <20061126094212.fde8cce7.seanlkml@sympatico.ca>
2006-11-26 15:05     ` Nicolas Vilz
2006-11-27  8:48       ` Junio C Hamano
2006-11-27 10:50         ` Nicolas Vilz
2006-11-27  6:54     ` Shawn Pearce
2006-11-27  7:49       ` Jakub Narebski
2006-11-27 12:56       ` Sean
     [not found]       ` <20061127075650.81a5a850.seanlkml@sympatico.ca>
2006-11-27 17:02         ` Shawn Pearce
2006-11-27 17:38           ` Sean

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).