Skip to content

Commit 15a54fb

Browse files
artagnongitster
authored andcommitted
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>
1 parent 629b60a commit 15a54fb

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

contrib/completion/git-prompt.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ __git_ps1 ()
359359
fi
360360
fi
361361

362+
local z="${GIT_PS1_STATESEPARATOR-" "}"
362363
local f="$w$i$s$u"
363364
if [ $pcmode = yes ]; then
364365
local gitstring=
@@ -384,7 +385,7 @@ __git_ps1 ()
384385
gitstring="\[$branch_color\]$branchstring\[$c_clear\]"
385386

386387
if [ -n "$w$i$s$u$r$p" ]; then
387-
gitstring="$gitstring "
388+
gitstring="$gitstring$z"
388389
fi
389390
if [ "$w" = "*" ]; then
390391
gitstring="$gitstring\[$bad_color\]$w"
@@ -400,13 +401,13 @@ __git_ps1 ()
400401
fi
401402
gitstring="$gitstring\[$c_clear\]$r$p"
402403
else
403-
gitstring="$c${b##refs/heads/}${f:+ $f}$r$p"
404+
gitstring="$c${b##refs/heads/}${f:+$z$f}$r$p"
404405
fi
405406
gitstring=$(printf -- "$printf_format" "$gitstring")
406407
PS1="$ps1pc_start$gitstring$ps1pc_end"
407408
else
408409
# 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"
410411
fi
411412
fi
412413
}

0 commit comments

Comments
 (0)