Re: git-PS1 bash prompt setting

Previous thread: Re: [PATCH] Make "git checkout <branch> <path>" work when <path> is a directory. by Junio C Hamano on Friday, November 17, 2006 - 4:15 am. (1 message)

Next thread: Re: [DRAFT] Branching and merging with git by Jakub Narebski on Friday, November 17, 2006 - 5:37 am. (1 message)
To: Sean <seanlkml@...>
Cc: Theodore Tso <tytso@...>, <git@...>
Date: Friday, November 17, 2006 - 4:38 am

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
Nicolas
-

To: Nicolas Vilz <niv@...>
Cc: Theodore Tso <tytso@...>, <git@...>
Date: Friday, November 17, 2006 - 5:20 am

On Fri, 17 Nov 2006 09:38:02 +0100

Sorry bout that, I knew it was a bit fragile. Was rather
comical reading Junio's recent message about all the things not
to do if you want portable shell code and noticing my 6 line script
did 90% of them ;o) Strange though, I downloaded Bash 3.2
and gave it a try and didn't see the problem here..

Wanna try this small change, to see if it helps? :

#!/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}]$ "

-

To: Sean <seanlkml@...>
Cc: <git@...>
Date: Sunday, November 19, 2006 - 2:28 am

Maybe I should have been more explicit when I said "${paremeter##word}
and friends". Might not have been obvious, but I only meant the
following four: %, %%, # and ##.

${parameter/pattern/string} and ${parameter//pattern/string} are
not even in POSIX.

-

Previous thread: Re: [PATCH] Make "git checkout <branch> <path>" work when <path> is a directory. by Junio C Hamano on Friday, November 17, 2006 - 4:15 am. (1 message)

Next thread: Re: [DRAFT] Branching and merging with git by Jakub Narebski on Friday, November 17, 2006 - 5:37 am. (1 message)