From 1f923a90ad5611f3e599da5ff208bc0eb9771fac Mon Sep 17 00:00:00 2001 From: Robert R Evans Date: Sun, 3 Oct 2010 09:41:36 -0700 Subject: [PATCH] Added more color support for git themeing --- template/bash_profile.template.bash | 8 ++++++++ themes/base.theme.bash | 19 ++++++++++++++----- themes/bobby/bobby.theme.bash | 2 +- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/template/bash_profile.template.bash b/template/bash_profile.template.bash index 0991d90..a92523c 100644 --- a/template/bash_profile.template.bash +++ b/template/bash_profile.template.bash @@ -8,13 +8,21 @@ export PATH=$PATH:~/.gem/ruby/1.8/bin:/opt/nginx/sbin # Path to the bash it configuration export BASH=$HOME/.bash_it +export LOAD_COLORS=$BASH/themes/base.theme.bash # Lock and Load a custom theme file # location /.bash_it/themes/ export BASH_THEME='bobby' +# Load the color configuration file, if you want to add colors to the GIT THEME PROMPTs +source $LOAD_COLORS + # Your place for hosting Git repos. I use this for private repos. export GIT_HOSTING='git@git.domain.com' +export GIT_THEME_PROMPT_DIRTY=' ${RED}✗${LIGHT_GREEN}' # This shows how to use sample the colors +export GIT_THEME_PROMPT_CLEAN=' ✓' +export GIT_THEME_PROMPT_PREFIX='(' +export GIT_THEME_PROMPT_SUFFIX=')' # Set my editor and git editor export EDITOR="/usr/bin/mate -w" diff --git a/themes/base.theme.bash b/themes/base.theme.bash index eaf0e83..3db83b0 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -17,15 +17,19 @@ ORANGE=$'\e[33;40m' NORMAL=$'\e[00m' # LIGHT COLORS -LIGHT_BLUE=$'\e[1;34m' LIGHT_GREEN=$'\e[1;32m' -LIGHT_CYAN=$'\e[1;36m' LIGHT_RED=$'\e[1;31m' -LIGHT_PURPLE=$'\e[1;35m' +LIGHT_BLUE=$'\e[1;34m' LIGHT_YELLOW=$'\e[1;33m' +LIGHT_PURPLE=$'\e[1;35m' +LIGHT_CYAN=$'\e[1;36m' LIGHT_GRAY=$'\e[0;37m' + + + + # Stolen from Steve Losh function prompt_char { git branch >/dev/null 2>/dev/null && echo '±' && return @@ -34,9 +38,14 @@ function prompt_char { } function parse_git_dirty { - [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" + if [[ -n $(git status -s 2> /dev/null) ]]; then + echo "$GIT_THEME_PROMPT_DIRTY" + else + echo "$GIT_THEME_PROMPT_CLEAN" + fi } function parse_git_branch { - git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" + ref=$(git symbolic-ref HEAD 2> /dev/null) || return + echo "$GIT_THEME_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$GIT_THEME_PROMPT_SUFFIX" } \ No newline at end of file diff --git a/themes/bobby/bobby.theme.bash b/themes/bobby/bobby.theme.bash index 724eb2c..9528425 100644 --- a/themes/bobby/bobby.theme.bash +++ b/themes/bobby/bobby.theme.bash @@ -1,2 +1,2 @@ #!/bin/bash -export PS1='${LIGHT_BLUE}$(prompt_char)${LIGHT_GREEN} $(parse_git_branch) ${ORANGE}\h ${NORMAL}in ${GREEN}\w ${NORMAL}→ ' \ No newline at end of file +export PS1='${LIGHT_BLUE}$(prompt_char)${LIGHT_GREEN}$(parse_git_branch) ${ORANGE}\h ${NORMAL}in ${GREEN}\w ${NORMAL}→ ' \ No newline at end of file -- 2.17.1