You could write a shell function that takes a string as an argument and inserts the appropriate color codes based on string substitution, and then just pass the results of __git_ps1 to that function.
Something like the following might work:
function __my_git_colorize_ps1 () {
echo "$1" | while read -N 1 char; do
case "$char" in
\*) echo -n $'\e[34m*\e[m';;
+) echo -n $'\e[31m+\e[m';;
$) echo -n $'\e[32m$\e[m';;
%) echo -n $'\e[1;34m%\e[m';;
\<|\>) echo -n $'\e[31m'"$char"$'\e[m';;
*) echo -n "$char";;
esac
done
}-Kevin Ballard
On Oct 30, 2010, at 9:14 PM, Sebastien Douche wrote:
Show 18 quoted lines
> Hi,
> the prompt (git-completion.bash) bundled with git is the most
> "advanced" I found on the web. But I would add colors for "status".
> Example show: * (unstaged) in blue, + (staged in red), $ (stashed) in
> green, % (untracked) in bold blue and < > <> (upstream indicator) in
> red.
>
> How make this?
>
> Cheers
>
> --
> Sebastien Douche <sdouche@gmail.com>
> Twitter: http://bit.ly/afkrK (agile, lean, python, git, open source)
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html