Allow different color for master branch

- add $GIT_PROMPT_MASTER_BRANCH - color for master branch
- add $GIT_PROMPT_MASTER_BRANCHES - branch name(s) that use
  $GIT_PROMPT_MASTER_BRANCH color, 'master' by default)

All other branches will continue to use $GIT_PROMPT_BRANCH

Fixes https://github.com/magicmonty/bash-git-prompt/issues/311
master
Christian Boltz 8 years ago
parent 50eb8fbeaf
commit 4b8c8da3ef
No known key found for this signature in database
GPG Key ID: C6A682EA63C82F1C
  1. 10
      gitprompt.sh
  2. 7
      themes/Custom.bgptemplate
  3. 7
      themes/Default.bgptheme

@ -519,7 +519,15 @@ function updatePrompt() {
local NEW_PROMPT="$EMPTY_PROMPT"
if [[ -n "$git_status_fields" ]]; then
local STATUS_PREFIX="${PROMPT_LEADING_SPACE}${GIT_PROMPT_PREFIX}${GIT_PROMPT_BRANCH}\${GIT_BRANCH}${ResetColor}${GIT_FORMATTED_UPSTREAM}"
case "$GIT_BRANCH" in
$GIT_PROMPT_MASTER_BRANCHES)
local STATUS_PREFIX="${PROMPT_LEADING_SPACE}${GIT_PROMPT_PREFIX}${GIT_PROMPT_MASTER_BRANCH}\${GIT_BRANCH}${ResetColor}${GIT_FORMATTED_UPSTREAM}"
;;
*)
local STATUS_PREFIX="${PROMPT_LEADING_SPACE}${GIT_PROMPT_PREFIX}${GIT_PROMPT_BRANCH}\${GIT_BRANCH}${ResetColor}${GIT_FORMATTED_UPSTREAM}"
;;
esac
local STATUS=""
# __add_status KIND VALEXPR INSERT

@ -14,6 +14,7 @@ override_git_prompt_colors() {
# GIT_PROMPT_SEPARATOR="|" # separates each item
# GIT_PROMPT_BRANCH="${Magenta}" # the git branch that is active in the current directory
# GIT_PROMPT_MASTER_BRANCH="${Magenta}" # used if the git branch that is active in the current directory is $GIT_PROMPT_MASTER_BRANCHES
# GIT_PROMPT_STAGED="${Red}●" # the number of staged files/directories
# GIT_PROMPT_CONFLICTS="${Red}✖ " # the number of files in conflict
# GIT_PROMPT_CHANGED="${Blue}✚ " # the number of changed files
@ -53,6 +54,12 @@ override_git_prompt_colors() {
# GIT_PROMPT_SYMBOLS_BEHIND="↓·" # The symbol for "n versions behind of origin"
# GIT_PROMPT_SYMBOLS_PREHASH=":" # Written before hash of commit, if no name could be found
# GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING="L" # This symbol is written after the branch, if the branch is not tracked
# branch name(s) that will use $GIT_PROMPT_MASTER_BRANCH color
# To specify multiple branches, use
# shopt -s extglob
# GIT_PROMPT_MASTER_BRANCHES='@(master|production)'
# GIT_PROMPT_MASTER_BRANCHES="master"
}
reload_git_prompt_colors "Custom"

@ -42,6 +42,7 @@ define_undefined_git_prompt_colors() {
if [ -z ${GIT_PROMPT_SEPARATOR+x} ]; then GIT_PROMPT_SEPARATOR="|"; fi # separates each item
if [ -z ${GIT_PROMPT_BRANCH+x} ]; then GIT_PROMPT_BRANCH="${Magenta}"; fi # the git branch that is active in the current directory
if [ -z ${GIT_PROMPT_MASTER_BRANCH+x} ]; then GIT_PROMPT_MASTER_BRANCH="${Magenta}"; fi # used if the git branch that is active in the current directory is $GIT_PROMPT_MASTER_BRANCHES
if [ -z ${GIT_PROMPT_STAGED+x} ]; then GIT_PROMPT_STAGED="${Red}●"; fi # the number of staged files/directories
if [ -z ${GIT_PROMPT_CONFLICTS+x} ]; then GIT_PROMPT_CONFLICTS="${Red}✖ "; fi # the number of files in conflict
if [ -z ${GIT_PROMPT_CHANGED+x} ]; then GIT_PROMPT_CHANGED="${Blue}✚ "; fi # the number of changed files
@ -88,6 +89,12 @@ define_undefined_git_prompt_colors() {
if [ -z ${GIT_PROMPT_SYMBOLS_BEHIND+x} ]; then GIT_PROMPT_SYMBOLS_BEHIND="↓·"; fi # The symbol for "n versions behind of origin"
if [ -z ${GIT_PROMPT_SYMBOLS_PREHASH+x} ]; then GIT_PROMPT_SYMBOLS_PREHASH=":"; fi # Written before hash of commit, if no name could be found
if [ -z ${GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING+x} ]; then GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING="L"; fi # This symbol is written after the branch, if the branch is not tracked
# branch name(s) that will use $GIT_PROMPT_MASTER_BRANCH color
# To specify multiple branches, use
# shopt -s extglob
# GIT_PROMPT_MASTER_BRANCHES='@(master|production)'
if [ -z ${GIT_PROMPT_MASTER_BRANCHES+x} ]; then GIT_PROMPT_MASTER_BRANCHES="master"; fi
}
# call only from theme file

Loading…
Cancel
Save