Skip to content

Commit

Permalink
Fixed Issue #6: Definig $PROMPT_START $PROMPT_END out of gitprompt.sh
Browse files Browse the repository at this point in the history
It is now possible to override PROMPT_START and PROMPT_END by exporting the variables GIT_PROMPT_START and GIT_PROMPT_END
  • Loading branch information
magicmonty committed Jul 3, 2013
1 parent 31773c1 commit 43a4f3c
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions gitprompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}` ]]
Expand All @@ -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
Expand Down

0 comments on commit 43a4f3c

Please sign in to comment.