From 1b5bd2248124dc085af07bed6ddc39f3379b82d9 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Thu, 30 Jan 2014 17:51:00 +0900 Subject: [PATCH] Add config variable to toggle leading space in front of Git Prompt Set GIT_PROMPT_LEADING_SPACE to 0 if you do not want a leading space in front of the prompt. If not set or to any other value a leading space is printed out. --- gitprompt.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gitprompt.sh b/gitprompt.sh index ead38f4..f12be6f 100755 --- a/gitprompt.sh +++ b/gitprompt.sh @@ -97,6 +97,13 @@ function git_prompt_config() PROMPT_END="${GIT_PROMPT_END}" fi + # set GIT_PROMPT_LEADING_SPACE to 0 if you want to have no leading space in front of the GIT prompt + if [ "x${GIT_PROMPT_LEADING_SPACE}" == "x0" ]; then + PROMPT_LEADING_SPACE="" + else + PROMPT_LEADING_SPACE=" " + fi + if [[ -n "${VIRTUAL_ENV}" ]]; then EMPTY_PROMPT="${Blue}($(basename "${VIRTUAL_ENV}"))${ResetColor} ${PROMPT_START}$($prompt_callback)${PROMPT_END}" else @@ -166,6 +173,7 @@ function updatePrompt() { local GIT_PROMPT_UNTRACKED local GIT_PROMPT_STASHED local GIT_PROMPT_CLEAN + local PROMPT_LEADING_SPACE local PROMPT_START local PROMPT_END local EMPTY_PROMPT @@ -192,7 +200,7 @@ function updatePrompt() { local GIT_CLEAN=${GitStatus[7]} if [[ -n "${GitStatus}" ]]; then - local STATUS=" ${GIT_PROMPT_PREFIX}${GIT_PROMPT_BRANCH}${GIT_BRANCH}${ResetColor}" + local STATUS="${PROMPT_LEADING_SPACE}${GIT_PROMPT_PREFIX}${GIT_PROMPT_BRANCH}${GIT_BRANCH}${ResetColor}" if [[ -n "${GIT_REMOTE}" ]]; then STATUS="${STATUS}${GIT_PROMPT_REMOTE}${GIT_REMOTE}${ResetColor}"