summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugues Hiegel <hugues@hiegel.fr>2008-03-07 01:09:26 +0100
committerHugues Hiegel <hugues@hiegel.fr>2008-03-07 14:15:23 +0100
commite2761ab1784145e286ce51297071ce2a85ca0d19 (patch)
tree788a6cb990725775940b13166b6f661a6364e2b3
parent2ad9e20123a840d5338ea2ad4c4684826cff3776 (diff)
Better git status/colors codes managment.
-rw-r--r--01_Functions.zsh10
-rw-r--r--11_Prompts.zsh17
2 files changed, 15 insertions, 12 deletions
diff --git a/01_Functions.zsh b/01_Functions.zsh
index aa96dea..809d85a 100644
--- a/01_Functions.zsh
+++ b/01_Functions.zsh
@@ -47,7 +47,7 @@ get_git_branch ()
{
local my_git_branch
- [ "$(git-ls-files . 2>&- | head -n 1)" == "" ] && return
+ [ "$( ( git-ls-tree HEAD . 2>&- ; git-ls-files . 2>&- ) | head -n 1)" == "" ] && return
# Get current working GIT branch
my_git_branch="$(git-branch 2>&- | grep -E '^\* ' | cut -c3-)"
@@ -75,13 +75,13 @@ get_git_status ()
if ( echo ${(s:/:)PWD} | grep "\.\<git\>" >/dev/null )
then
- my_git_status="$color[red];$color[bold]"
+ my_git_status="$COLOR_GIT_MANAGMENT"
elif [ "$(git-diff --cached 2>&- | grep '^diff ')" != "" ] ; then
- my_git_status="$color[yellow];$color[bold]"
+ my_git_status="$COLOR_GIT_CACHED"
elif [ "$(git-ls-files -m 2>&-)" != "" ] ; then
- my_git_status="$color[green];$color[bold]"
+ my_git_status="$COLOR_GIT_NOT_UP_TO_DATE"
else
- my_git_status="$color[blue]"
+ my_git_status="$COLOR_GIT_UP_TO_DATE"
fi
echo $my_git_status
diff --git a/11_Prompts.zsh b/11_Prompts.zsh
index 8817cc0..6012bb0 100644
--- a/11_Prompts.zsh
+++ b/11_Prompts.zsh
@@ -43,16 +43,19 @@ COLOR_PAREN="$color[reset];$color[cyan]"
COLOR_MAIL="$color[reset];$color[yellow];$color[bold]"
COLOR_BAR="$color[reset];$GENERIC;$color[bold]"
COLOR_BRACES=$COLOR_BAR
+COLOR_ERRR="$color[bold];$color[yellow]"
+COLOR_DATE="$color[reset];$GENERIC"
+COLOR_CMD="$color[reset]"
+COLOR_EXEC="$color[reset]"
COLOR_BRANCH_OR_REV="$color[reset];$GENERIC"
COLOR_NOT_UP_TO_DATE="$color[reset];$color[green];$color[bold]"
-COLOR_TO_BE_COMMITED="$color[reset];$color[yellow];$color[bold]"
+COLOR_TO_BE_COMMITED="$COLOR_ERRR"
-COLOR_CMD="$color[reset]"
-COLOR_EXEC="$color[reset]"
-
-COLOR_ERRR="$color[bold];$color[yellow]"
-COLOR_DATE="$color[reset];$GENERIC"
+COLOR_GIT_MANAGMENT="$color[reset];$color[red];$color[bold]"
+COLOR_GIT_CACHED="$color[reset];$COLOR_ERRR"
+COLOR_GIT_NOT_UP_TO_DATE="$color[reset];$COLOR_NOT_UP_TO_DATE"
+COLOR_GIT_UP_TO_DATE="$color[reset];$GENERIC"
## Prompts
#
@@ -123,7 +126,7 @@ old_precmd()
# get git status
GITBRANCH=$(get_git_branch)
- GITBRANCH=${GITBRANCH:+$C_$COLOR_DOUBLEDOT$_C:$C_$(get_git_status)$_C$GITBRANCH}
+ GITBRANCH=${GITBRANCH:+$C_$COLOR_DOUBLEDOT$_C:$C_"$(get_git_status)"$_C$GITBRANCH}
# First line of prompt, calculation of the remaining place
spaceleft=$((1 + $COLUMNS - $ERRORSIZE - $MAILSTATSIZE - $DATESIZE))