@@ -67,6 +67,18 @@ function gp_maybe_set_envar_to_path(){
67
67
return 1
68
68
}
69
69
70
+ # git_prompt_reset
71
+ #
72
+ # unsets selected GIT_PROMPT variables, causing the next prompt callback to
73
+ # recalculate them from scratch.
74
+
75
+ git_prompt_reset () {
76
+ local var
77
+ for var in GIT_PROMPT_DIR __GIT_PROMPT_COLORS_FILE __PROMPT_COLORS_FILE __GIT_STATUS_CMD ; do
78
+ unset $var
79
+ done
80
+ }
81
+
70
82
function git_prompt_config()
71
83
{
72
84
# Checking if root to change output
@@ -78,8 +90,8 @@ function git_prompt_config()
78
90
# prompt-colors.sh -- sets generic color names suitable for bash `PS1` prompt
79
91
# git-prompt-colors.sh -- sets the GIT_PROMPT color scheme, using names from prompt-colors.sh
80
92
81
- if gp_set_file_var __PROMPT_COLORS_SH prompt-colors.sh ; then
82
- source " $__PROMPT_COLORS_SH " # outsource the color defs
93
+ if gp_set_file_var __PROMPT_COLORS_FILE prompt-colors.sh ; then
94
+ source " $__PROMPT_COLORS_FILE " # outsource the color defs
83
95
else
84
96
echo 1>&2 " Cannot find prompt-colors.sh!"
85
97
fi
@@ -93,14 +105,15 @@ function git_prompt_config()
93
105
echo 1>&2 " Cannot find git-prompt-colors.sh!"
94
106
fi
95
107
96
- if [ " x $GIT_PROMPT_SHOW_LAST_COMMAND_INDICATOR " == " x1 " ]; then
108
+ if [ " $GIT_PROMPT_SHOW_LAST_COMMAND_INDICATOR " = 1 ]; then
97
109
if [ $GIT_PROMPT_LAST_COMMAND_STATE = 0 ]; then
98
110
LAST_COMMAND_INDICATOR=" $GIT_PROMPT_COMMAND_OK " ;
99
111
else
100
112
LAST_COMMAND_INDICATOR=" $GIT_PROMPT_COMMAND_FAIL " ;
101
113
fi
102
114
103
- LAST_COMMAND_INDICATOR=" ${LAST_COMMAND_INDICATOR/ _LAST_COMMAND_STATE_/ $GIT_PROMPT_LAST_COMMAND_STATE } "
115
+ # replace _LAST_COMMAND_STATE_ token with the actual state
116
+ LAST_COMMAND_INDICATOR=" ${LAST_COMMAND_INDICATOR/ _LAST_COMMAND_STATE_/ ${GIT_PROMPT_LAST_COMMAND_STATE} } "
104
117
fi
105
118
106
119
# Do this only once to define PROMPT_START and PROMPT_END
@@ -219,8 +232,6 @@ function updatePrompt() {
219
232
local PROMPT_START
220
233
local PROMPT_END
221
234
local EMPTY_PROMPT
222
- local GIT_PROMPT_FETCH_TIMEOUT
223
- local __GIT_STATUS_CMD
224
235
local Blue=" \[\033[0;34m\]"
225
236
226
237
git_prompt_config
0 commit comments