prompt: introduce GIT_PS1_STATESEPARATOR
A typical prompt looks like: artagnon|master *=:~/src/git$ ^ why do we have this space? Nobody has branch names that end with +, *, =, < or > anyway, so it doesn't serve the purpose of disambiguation. Make this separator configurable via GIT_PS1_STATESEPARATOR. This means that you can set it to "" and get this prompt: artagnon|master*=:~/src/git$ Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ramkumar Ramachandra committed
May 17, 2013 at 14:25 UTC
15a54fb8095502217fce7c7c6dd14e9066b62ebe
1 file changed
+4
-3
contrib/completion/git-prompt.sh
+4
-3
@@ -359,6 +359,7 @@ __git_ps1 ()
359
fi
360
fi
361
362
+ local z="${GIT_PS1_STATESEPARATOR-" "}"
363
local f="$w$i$s$u"
364
if [ $pcmode = yes ]; then
365
local gitstring=
@@ -384,7 +385,7 @@ __git_ps1 ()
385
gitstring="\[$branch_color\]$branchstring\[$c_clear\]"
386
387
if [ -n "$w$i$s$u$r$p" ]; then
387
- gitstring="$gitstring "
388
+ gitstring="$gitstring$z"
389
fi
390
if [ "$w" = "*" ]; then
391
gitstring="$gitstring\[$bad_color\]$w"
@@ -400,13 +401,13 @@ __git_ps1 ()
401
fi
402
gitstring="$gitstring\[$c_clear\]$r$p"
403
else
403
- gitstring="$c${b##refs/heads/}${f:+ $f}$r$p"
404
+ gitstring="$c${b##refs/heads/}${f:+$z$f}$r$p"
405
fi
406
gitstring=$(printf -- "$printf_format" "$gitstring")
407
PS1="$ps1pc_start$gitstring$ps1pc_end"
408
else
409
# NO color option unless in PROMPT_COMMAND mode
409
- printf -- "$printf_format" "$c${b##refs/heads/}${f:+ $f}$r$p"
410
+ printf -- "$printf_format" "$c${b##refs/heads/}${f:+$z$f}$r$p"
411
fi
412
fi
413
}