Skip to content

Commit 43a4f3c

Browse files
committed
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
1 parent 31773c1 commit 43a4f3c

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

gitprompt.sh

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,22 @@ function git_prompt_config()
5050
# local Time12a="(\$(date +%H:%M:%S))"
5151
# local Time12a="(\@))"
5252
local PathShort="\w"
53-
54-
PROMPT_START="${Yellow}${PathShort}${ResetColor}"
55-
PROMPT_END=" \n${White}${Time12a}${ResetColor} $ "
53+
54+
if [ "x${GIT_PROMPT_START}" == "x" ]; then
55+
PROMPT_START="${Yellow}${PathShort}${ResetColor}"
56+
else
57+
PROMPT_START="${GIT_PROMPT_START}"
58+
fi
59+
60+
if [ "x${GIT_PROMPT_END}" == "x" ]; then
61+
PROMPT_END=" \n${White}${Time12a}${ResetColor} $ "
62+
else
63+
PROMPT_END="${GIT_PROMPT_END}"
64+
fi
5665

5766
EMPTY_PROMPT="${PROMPT_START}${PROMPT_END}"
5867

59-
# fetch remote revisions every other $GIT_PROMPT_FETCH_TIMEOUT (default 5) minutes
68+
# fetch remote revisions every other $GIT_PROMPT_FETCH_TIMEOUT (default 5) minutes
6069
GIT_PROMPT_FETCH_TIMEOUT=${1-5}
6170
if [ "x$__GIT_STATUS_CMD" == "x" ]
6271
then
@@ -91,7 +100,7 @@ function setGitPrompt() {
91100
PS1="${EMPTY_PROMPT}"
92101
return
93102
fi
94-
103+
95104
local FETCH_HEAD="${repo}/.git/FETCH_HEAD"
96105
# Fech repo if local is stale for more than $GIT_FETCH_TIMEOUT minutes
97106
if [[ ! -e "${FETCH_HEAD}" || -e `find ${FETCH_HEAD} -mmin +${GIT_PROMPT_FETCH_TIMEOUT}` ]]
@@ -101,7 +110,7 @@ function setGitPrompt() {
101110

102111
local -a GitStatus
103112
GitStatus=($("${__GIT_STATUS_CMD}" 2>/dev/null))
104-
113+
105114
local GIT_BRANCH=${GitStatus[0]}
106115
local GIT_REMOTE=${GitStatus[1]}
107116
if [[ "." == "$GIT_REMOTE" ]]; then

0 commit comments

Comments
 (0)