Skip to content

Commit 6b9bb1c

Browse files
committed
Merge pull request #260 from ogr3/colors-as-function
Extract color definition loading as a function
2 parents 0ee3ef8 + 46ab557 commit 6b9bb1c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

gitprompt.sh

+11-5
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ function get_theme() {
6666
fi
6767
}
6868

69+
function git_prompt_load_colors() {
70+
if gp_set_file_var __PROMPT_COLORS_FILE prompt-colors.sh ; then
71+
# outsource the color defs
72+
source "$__PROMPT_COLORS_FILE"
73+
else
74+
echo 1>&2 "Cannot find prompt-colors.sh!"
75+
fi
76+
}
77+
6978
function git_prompt_load_theme() {
7079
get_theme
7180
local DEFAULT_THEME_FILE="${__GIT_PROMPT_DIR}/themes/Default.bgptheme"
@@ -74,6 +83,7 @@ function git_prompt_load_theme() {
7483
}
7584

7685
function git_prompt_list_themes() {
86+
git_prompt_load_colors
7787
git_prompt_dir
7888
get_theme
7989

@@ -207,11 +217,7 @@ function git_prompt_config() {
207217
# prompt-colors.sh -- sets generic color names suitable for bash 'PS1' prompt
208218
# git-prompt-colors.sh -- sets the GIT_PROMPT color scheme, using names from prompt-colors.sh
209219

210-
if gp_set_file_var __PROMPT_COLORS_FILE prompt-colors.sh ; then
211-
source "$__PROMPT_COLORS_FILE" # outsource the color defs
212-
else
213-
echo 1>&2 "Cannot find prompt-colors.sh!"
214-
fi
220+
git_prompt_load_colors
215221

216222
# source the user's ~/.git-prompt-colors.sh file, or the one that should be
217223
# sitting in the same directory as this script

0 commit comments

Comments
 (0)