summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugues Hiegel <hugues.hiegel@qosmos.com>2012-03-02 12:36:52 +0100
committerHugues Hiegel <hugues.hiegel@qosmos.com>2012-03-02 12:36:52 +0100
commitf4982398816e2dee92e0f7483b0c2c3456c3ec8d (patch)
treea825e8694f015ceba53e50bb92dba75113f168bc
parentce56e97857f9fcaaa9b6e7773e78c29a4dcc24b9 (diff)
[Prompts] Woaw.. Et voilà ! Now it colorizes only the *EFFECTIVE* git hash
-rw-r--r--01_Internal.zsh8
-rw-r--r--12_Prompts.zsh44
2 files changed, 17 insertions, 35 deletions
diff --git a/01_Internal.zsh b/01_Internal.zsh
index f11a2bc..b8bec64 100644
--- a/01_Internal.zsh
+++ b/01_Internal.zsh
@@ -164,6 +164,8 @@ __get_git_branch ()
fi
fi
+ my_git_branch="→"$my_git_branch"←"
+
# Rebase in progress ?
if [ -d $GIT_DIR/rebase-merge -o -d $GIT_DIR/rebase-apply ]
then
@@ -187,7 +189,6 @@ __get_git_branch ()
last=$(cat $REBASE_DIR/last)
fi
- # Then the result
my_git_branch="[$current/$last: "$(git name-rev --name-only "$(cat $REBASE_DIR/onto 2>/dev/null)" 2>/dev/null | __cleanup_git_branch_name)".."$(echo $my_git_branch)"]"
[ -r $REBASE_DIR/head-name ] && my_git_branch=$my_git_branch" "$(< $REBASE_DIR/head-name sed 's/^refs\///;s/^heads\///')
else
@@ -195,11 +196,6 @@ __get_git_branch ()
[ ! "$checkouted_branch" ] && my_git_branch="($my_git_branch)"
fi
- if [ "$(git status 2>&- | grep "new file" | head -n1)" != "" ] ; then
- # ADDED FILES
- my_git_branch=$my_git_branch
- fi
-
echo " "$my_git_branch
}
diff --git a/12_Prompts.zsh b/12_Prompts.zsh
index 4157d03..628c060 100644
--- a/12_Prompts.zsh
+++ b/12_Prompts.zsh
@@ -295,40 +295,26 @@ __update_prompt_elements()
then
if [ $spaceleft -lt $(( $PATHSIZE + $GITBRANCHSIZE )) ]
then
- local unbreakablegittail rebasing
-
- if [ "$(echo $GITBRANCH | grep "^ \[")" != "" ]
- then
- #
- # TODO : réduire la taille du hash, s'il y en a un.
- #
- rebasing=$GITBRANCH
- GITBRANCH=${${GITBRANCH/*../}/] */}
- fi
-
- # reduce the git-branch until it is shrinked to $minimalgitsize characters max.
- if [ $GITBRANCH[-1] = ")" ]
- then
- unbreakablegittail=${${(M)GITBRANCH%\~*}}
- [ "$unbreakablegittail" = "" -a $GITBRANCHSIZE -gt $minimalgitsize ] && unbreakablegittail=$GITBRANCH[-1]
- fi
- if [ $GITBRANCHSIZE -gt $minimalgitsize ]
- then
- GITBRANCHCHUNK=$(( $GITBRANCHSIZE - ($spaceleft - $PATHSIZE) ))
- [ $((${#GITBRANCH} - $GITBRANCHCHUNK)) -lt $minimalgitsize ] && GITBRANCHCHUNK=$((${#GITBRANCH} - $minimalgitsize))
- fi
- GITBRANCH=`print -Pn "%"$(( (${#GITBRANCH} - $GITBRANCHCHUNK) - ${#unbreakablegittail}))">¬>"${GITBRANCH%\~*}${unbreakablegittail:+"%"${#unbreakablegittail}"<<"$GITBRANCH}`
-
- if [ -n "$rebasing" ]
- then
- GITBRANCH=${rebasing/..*]/..$GITBRANCH]}
- fi
+ CHUNKABLE=${${GITBRANCH/*→/}/←*/}
+
+ # reduce the git-branch until it is shrinked to $minimalgitsize characters max.
+ if [ $GITBRANCHSIZE -gt $minimalgitsize ]
+ then
+ GITBRANCHCHUNK=$(( $GITBRANCHSIZE - ($spaceleft - $PATHSIZE) ))
+ [ $((${#CHUNKABLE} - $GITBRANCHCHUNK)) -lt $minimalgitsize ] && GITBRANCHCHUNK=$((${#CHUNKABLE} - $minimalgitsize))
+ fi
+ CHUNKABLE=`print -Pn "%"$(( ${#CHUNKABLE} - $GITBRANCHCHUNK ))">¬>"${CHUNKABLE%\~*}`
+
+ GITBRANCH=${GITBRANCH/→*←/→$CHUNKABLE←}
fi
fi
# then we reduce the path until it reaches the last path element,
spaceleft=$(($spaceleft - $GITBRANCHSIZE))
[ $spaceleft -lt $minimalpathsize ] && spaceleft=$minimalpathsize
- GITBRANCH=${GITBRANCH:+$C_"$(__get_git_status)"$_C$GITBRANCH}"$(__get_guilt_series)$C_$color[none]$_C"
+ if [ -n "$GITBRANCH" ]
+ then
+ GITBRANCH=$C_$_prompt_colors[soft_generic]$_C${${GITBRANCH/→/$C_"$(__get_git_status)"$_C}/←/$C_$_prompt_colors[soft_generic]$_C}"$(__get_guilt_series)$C_$color[none]$_C"
+ fi
CURDIR="$C_$_prompt_colors[path]$_C%`echo $spaceleft`<..<"$MY_PATH"%<<$C_$color[none]$_C"
[ "$DEBUG" = "yes" ] && echo
}