Skip to content

Commit

Permalink
Merge pull request #260 from ogr3/colors-as-function
Browse files Browse the repository at this point in the history
Extract color definition loading as a function
  • Loading branch information
magicmonty committed Jun 9, 2016
2 parents 0ee3ef8 + 46ab557 commit 6b9bb1c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions gitprompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ function get_theme() {
fi
}

function git_prompt_load_colors() {
if gp_set_file_var __PROMPT_COLORS_FILE prompt-colors.sh ; then
# outsource the color defs
source "$__PROMPT_COLORS_FILE"
else
echo 1>&2 "Cannot find prompt-colors.sh!"
fi
}

function git_prompt_load_theme() {
get_theme
local DEFAULT_THEME_FILE="${__GIT_PROMPT_DIR}/themes/Default.bgptheme"
Expand All @@ -74,6 +83,7 @@ function git_prompt_load_theme() {
}

function git_prompt_list_themes() {
git_prompt_load_colors
git_prompt_dir
get_theme

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

if gp_set_file_var __PROMPT_COLORS_FILE prompt-colors.sh ; then
source "$__PROMPT_COLORS_FILE" # outsource the color defs
else
echo 1>&2 "Cannot find prompt-colors.sh!"
fi
git_prompt_load_colors

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

0 comments on commit 6b9bb1c

Please sign in to comment.