From 43a4f3c9eee161b31c7756ac00e5d521b9c29b5b Mon Sep 17 00:00:00 2001 From: Martin Gondermann Date: Wed, 3 Jul 2013 10:57:04 +0200 Subject: [PATCH] Fixed Issue #6: Definig $PROMPT_START $PROMPT_END out of gitprompt.sh It is now possible to override PROMPT_START and PROMPT_END by exporting the variables GIT_PROMPT_START and GIT_PROMPT_END --- gitprompt.sh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/gitprompt.sh b/gitprompt.sh index bc5cc654..10e14023 100644 --- a/gitprompt.sh +++ b/gitprompt.sh @@ -50,13 +50,22 @@ function git_prompt_config() # local Time12a="(\$(date +%H:%M:%S))" # local Time12a="(\@))" local PathShort="\w" - - PROMPT_START="${Yellow}${PathShort}${ResetColor}" - PROMPT_END=" \n${White}${Time12a}${ResetColor} $ " + + if [ "x${GIT_PROMPT_START}" == "x" ]; then + PROMPT_START="${Yellow}${PathShort}${ResetColor}" + else + PROMPT_START="${GIT_PROMPT_START}" + fi + + if [ "x${GIT_PROMPT_END}" == "x" ]; then + PROMPT_END=" \n${White}${Time12a}${ResetColor} $ " + else + PROMPT_END="${GIT_PROMPT_END}" + fi EMPTY_PROMPT="${PROMPT_START}${PROMPT_END}" - # fetch remote revisions every other $GIT_PROMPT_FETCH_TIMEOUT (default 5) minutes + # fetch remote revisions every other $GIT_PROMPT_FETCH_TIMEOUT (default 5) minutes GIT_PROMPT_FETCH_TIMEOUT=${1-5} if [ "x$__GIT_STATUS_CMD" == "x" ] then @@ -91,7 +100,7 @@ function setGitPrompt() { PS1="${EMPTY_PROMPT}" return fi - + local FETCH_HEAD="${repo}/.git/FETCH_HEAD" # Fech repo if local is stale for more than $GIT_FETCH_TIMEOUT minutes if [[ ! -e "${FETCH_HEAD}" || -e `find ${FETCH_HEAD} -mmin +${GIT_PROMPT_FETCH_TIMEOUT}` ]] @@ -101,7 +110,7 @@ function setGitPrompt() { local -a GitStatus GitStatus=($("${__GIT_STATUS_CMD}" 2>/dev/null)) - + local GIT_BRANCH=${GitStatus[0]} local GIT_REMOTE=${GitStatus[1]} if [[ "." == "$GIT_REMOTE" ]]; then