Allow settings custom git prompt

This gives us ability to use string substitution for changing e.g. how
branch name is displayed.
This commit is contained in:
Dawid Kurek
2016-01-26 21:11:12 +01:00
parent 4126cdb114
commit d3f4997582

View File

@@ -160,6 +160,9 @@ fi
if [ ! -n "${BULLETTRAIN_GIT_EXTENDED+1}" ]; then
BULLETTRAIN_GIT_EXTENDED=true
fi
if [ ! -n "${BULLETTRAIN_GIT_PROMPT_CMD+1}" ]; then
BULLETTRAIN_GIT_PROMPT_CMD="\$(git_prompt_info)"
fi
# HG
if [ ! -n "${BULLETTRAIN_HG_SHOW+1}" ]; then
@@ -343,7 +346,7 @@ prompt_git() {
return
fi
local ref dirty mode repo_path
local ref dirty mode repo_path git_prompt
repo_path=$(git rev-parse --git-dir 2>/dev/null)
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
@@ -352,10 +355,11 @@ prompt_git() {
fi
prompt_segment $BULLETTRAIN_GIT_BG $BULLETTRAIN_GIT_FG
eval git_prompt=${BULLETTRAIN_GIT_PROMPT_CMD}
if [[ $BULLETTRAIN_GIT_EXTENDED == true ]]; then
echo -n $(git_prompt_info)$(git_prompt_status)
echo -n ${git_prompt}$(git_prompt_status)
else
echo -n $(git_prompt_info)
echo -n ${git_prompt}
fi
fi
}