summaryrefslogtreecommitdiff
path: root/12_Prompts.zsh
diff options
context:
space:
mode:
authorHugues Hiegel <hugues.hiegel@qosmos.com>2013-08-06 10:30:34 +0200
committerHugues Hiegel <hugues.hiegel@qosmos.com>2013-08-06 16:15:00 +0200
commit5cef725a76808a81e58248f79e1404ca8a7e008a (patch)
tree306b33eee5e3139016639d78535b80755ac1d1be /12_Prompts.zsh
parent3d6a612651035f831ea3049747e4a1dcd6d879ed (diff)
[Git] submodules statuses shown in taskbar
Diffstat (limited to '12_Prompts.zsh')
-rw-r--r--12_Prompts.zsh95
1 files changed, 30 insertions, 65 deletions
diff --git a/12_Prompts.zsh b/12_Prompts.zsh
index 6afbc09..dc6ffdc 100644
--- a/12_Prompts.zsh
+++ b/12_Prompts.zsh
@@ -157,6 +157,13 @@ __ssh_gpg_agents ()
}
PS1_TASKBAR+=(__ssh_gpg_agents)
+__display ()
+{
+ __debug -n " Display..."
+ echo ${DISPLAY:+$C_$_prompt_colors[display]$_C"("$DISPLAY")"}
+ __debug
+}
+PS1_TASKBAR+=(__display)
__vcsbranch ()
{
@@ -204,69 +211,35 @@ __vcsbranch ()
# get git status
#
- GITBRANCH=$(__get_gcl_branch git)
- GITBRANCHSIZE=${#GITBRANCH}
- [ $GITBRANCHSIZE -gt 0 ] && GITBRANCHSIZE=$(($GITBRANCHSIZE))
-
- #
- #__debug -n " Path..."
- #PATHSIZE=$(print -Pn $CURDIR)
- #PATHSIZE=${#PATHSIZE}
- #__debug
- #__debug -n " Resize path / gitbranch..."
- #spaceleft=`__expand_text "%n@%m${DISPLAY:+($DISPLAY)} $ ls -laCdtrux $DATE"`
- #spaceleft=$(($COLUMNS - ${#spaceleft}))
- ##minimalpathsize=`print -Pn "../%1~"`
- ##minimalpathsize=${#minimalpathsize}
- #minimalpathsize=10
- #minimalgitsize=10 # git-abbrev-commit-ish...
- #if [ $GITBRANCHSIZE -gt 0 ]
- #then
- # if [ $spaceleft -lt $(( $PATHSIZE + $GITBRANCHSIZE )) ]
- # then
- # 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:-0} ))">¬>"${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
- #__debug
-
- 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"
-
- # Get recursive submodules statuses
- GIT_DIR=$(git rev-parse --git-dir)
- for SUBMODULE in $(git config --get core.recursive)
- do
- pushd $(dirname $GIT_DIR)/$SUBMODULE >/dev/null
- SUBBRANCH=${$(__get_git_branch)//→master←/→…←}
- SUBSTATUS=$(__get_git_status)
- popd >/dev/null
- GITBRANCH+=$C_$color[black]$_C"₊"$C_$_prompt_colors[soft_generic]$_C
- GITBRANCH+=${${SUBBRANCH/→/$C_"$SUBSTATUS"$_C}/←/$C_$_prompt_colors[soft_generic]$_C}
- GITBRANCH+=$C_$color[none]$_C
- done
- fi
-
-
+ GITBRANCH=$(__get_git_fullstatus)
[ -n "$GITBRANCH" ] && vcsbranch+=${vcsbranch:+ }$GITBRANCH
echo $vcsbranch
}
PS1_EXTRA_INFO+=(__vcsbranch)
+__subvcsbranches () {
+ local GITBRANCH
+
+ GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
+ [ "$( ( git ls-files ; git ls-tree HEAD . ) 2>&- | head -n1)" = "" -a \
+ \( ! -d .git -o -z "$GIT_DIR" \) -a \
+ "$(git rev-parse --is-inside-git-dir 2>&-)" != "true" ] && return
+
+ # Get recursive submodules statuses
+ for SUBMODULE in $(git config --get zsh.recurse-dirs)
+ do
+ if [ -d $(dirname $GIT_DIR)/$SUBMODULE ]
+ then
+ GITBRANCH+=${GITBRANCH:+$(tput cuf1)}
+ GITBRANCH+=$(__get_git_fullstatus $(dirname $GIT_DIR)/$SUBMODULE)
+ fi
+ done
+ echo $GITBRANCH
+
+}
+PS1_TASKBAR+=(__subvcsbranches)
+
__redefine_prompt ()
{
case "$_yeahconsole" in
@@ -291,14 +264,6 @@ __show_date()
echo $(tput cub $COLUMNS ; tput cuf $(($COLUMNS - $DATESIZE)))$DATE
}
-__display ()
-{
- __debug -n " Display..."
- echo ${DISPLAY:+$C_$_prompt_colors[display]$_C"("$DISPLAY")"}
- __debug
-}
-PS1_TASKBAR+=(__display)
-
__display_vi_mode()
{
__debug -n " vimode..."