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}]$ "
From: Johannes Schindelin <hidden> Date: 2016-08-11 19:33:38
Hi,
On Thu, 16 Nov 2006, Sean wrote:
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]\$ ")'
I actually like that very much! So much that I tried to implement this as
an option to an existing builtin (I did not want to clutter the list of
commands any more...).
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?
Ciao,
Dscho
On Sun, 26 Nov 2006 15:27:07 +0100 (CET)
Johannes Schindelin [off-list ref] 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?
From: Johannes Schindelin <hidden> Date: 2016-08-11 20:31:59
Hi,
On Sun, 26 Nov 2006, Sean wrote:
On Sun, 26 Nov 2006 15:27:07 +0100 (CET)
Johannes Schindelin [off-list ref] wrote:
quoted
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?