summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--01_Internal.zsh93
-rw-r--r--12_Prompts.zsh14
-rw-r--r--net:foret/Prompts.zsh2
-rw-r--r--net:foret/user:hiegel/Hashes.zsh1
4 files changed, 61 insertions, 49 deletions
diff --git a/01_Internal.zsh b/01_Internal.zsh
index eafc0a4..7cd2aa8 100644
--- a/01_Internal.zsh
+++ b/01_Internal.zsh
@@ -193,25 +193,25 @@ __get_git_branch ()
commit_ish=$(git rev-parse --verify HEAD 2>/dev/null)
# Get current working GIT branch
- my_git_branch="$(git symbolic-ref --short -q HEAD)"
+ my_git_branch="$(git branch 2>&- | grep -E '^\* ' | cut -c3-)"
# for future use
checkouted_branch=$my_git_branch
- if [ ! "$my_git_branch" ]
+ if [ "$my_git_branch" != "" ]
then
- # Not on a working GIT branch. Get the named current commit-ish inside parenthesis
- [ ! "$my_git_branch" ] &&\
+ # If not on a working GIT branch, get the named current commit-ish inside parenthesis
+ [ "$my_git_branch" = "(no branch)" ] &&\
checkouted_branch="" && \
my_git_branch="$(git name-rev --name-only --always --no-undefined HEAD 2>&- | __cleanup_git_branch_name)"
- #else
- # # Initial commit
- # if [ -L $GIT_DIR/HEAD -a ! -f $GIT_DIR/HEAD ]
- # then
- # my_git_branch="$(basename $(readlink -f $GIT_DIR/HEAD))"
- # else
- # my_git_branch="$(basename $GIT_DIR/$(cat $GIT_DIR/HEAD | sed 's/^\([0-9a-f]\{2\}\)\([0-9a-f]\{38\}\)$/objects\/\1\/\2/;s/^ref: //'))"
- # fi
+ else
+ # Initial commit
+ if [ -L $GIT_DIR/HEAD -a ! -f $GIT_DIR/HEAD ]
+ then
+ my_git_branch="$(basename $(readlink -f $GIT_DIR/HEAD))"
+ else
+ my_git_branch="$(basename $GIT_DIR/$(cat $GIT_DIR/HEAD | sed 's/^\([0-9a-f]\{2\}\)\([0-9a-f]\{38\}\)$/objects\/\1\/\2/;s/^ref: //'))"
+ fi
fi
__debug
@@ -353,46 +353,45 @@ __get_git_tracking_status() {
local git_tracking_status=""
__debug -n " tracking..."
- my_git_branch="$(git symbolic-ref --short -q HEAD)"
- if [ "$my_git_branch" ]
+ my_git_branch="$(git branch 2>&- | grep -E '^\* ' | cut -c3-)"
+ if [ "$my_git_branch" != "(no branch)" -a ! "$(git config --get branch.$my_git_branch.remote)" ]
then
- local _upstream="$(git rev-parse --revs-only HEAD@\{upstream\} 2>/dev/null)"
- if [ ! "$_upstream" ]
+ git_tracking_status=$C_$_gcl_colors[untracked]$_C"✖"
+ fi
+ __debug
+
+ __debug -n " behind/ahead..."
+ # Show number of stashed commits by appending '+' signs for each
+ if [ "$(git rev-parse --is-inside-git-dir)" != "true" -a "$(git config --get core.bare)" != "true" ]
+ then
+ local _ahead=0 ;
+ local _behind=0 ;
+ eval $(git status . | sed -n '
+ /^#$/ { q }
+ s/^# and have \([0-9]\+\) and \([0-9]\+\) different.*/_ahead=\1;\n_behind=\2;\n/p ;
+ s/^# Your branch is \(behind\|ahead\) .* \([0-9]\+\) commit.*/_\1=\2;\n/p ;
+ ')
+
+ # ᛨ ᛪ ⇅ ↟↟ ⇶ ⇶ ⇵ ⌥ ⬆ ⬇ ⬌ ⬍ ⤱ ⤲ ✖ ➠ ➟ ⤴ ⎇⬋⬉⬉⬈⬌⬍⬅⬄
+
+ if [ $_behind -gt 0 ]
then
- git_tracking_status=$C_$_gcl_colors[untracked]$_C"✖"
- else
- __debug
- __debug -n " behind/ahead..."
- # Show number of stashed commits by appending '+' signs for each
- if [ "$(git rev-parse --is-inside-git-dir)" != "true" -a "$(git config --get core.bare)" != "true" ]
+ git_tracking_status+=$C_$_gcl_colors[ffwd]$_C
+ [ $_behind -gt 1 ] && git_tracking_status+="$(echo $_behind | _subscript_number)"
+ git_tracking_status+="⬇"
+ fi
+ if [ $_ahead -gt 0 ]
+ then
+ if [ $_behind -gt 0 ]
then
- local _ahead=0 ;
- local _behind=0 ;
- _ahead=$( git rev-list --count ${_upstream}..${my_git_branch})
- _behind=$(git rev-list --count ${my_git_branch}..${_upstream})
-
- # ᛨ ᛪ ⇅ ↟↟ ⇶ ⇶ ⇵ ⌥ ⬆ ⬇ ⬌ ⬍ ⤱ ⤲ ✖ ➠ ➟ ⤴ ⎇⬋⬉⬉⬈⬌⬍⬅⬄
-
- if [ $_behind -gt 0 ]
- then
- git_tracking_status+=$C_$_gcl_colors[ffwd]$_C
- [ $_behind -gt 1 ] && git_tracking_status+="$(echo $_behind | _subscript_number)"
- git_tracking_status+="⬇"
- fi
- if [ $_ahead -gt 0 ]
- then
- if [ $_behind -gt 0 ]
- then
- git_tracking_status+=$C_$_prompt_colors[generic]$_C
- else
- git_tracking_status+=$C_$_gcl_colors[cached]$_C
- fi
- git_tracking_status+="⬆"
- [ $_ahead -gt 1 ] && git_tracking_status+="$(echo $_ahead | _subscript_number)"
- fi
+ git_tracking_status+=$C_$_prompt_colors[generic]$_C
+ else
+ git_tracking_status+=$C_$_gcl_colors[cached]$_C
fi
+ git_tracking_status+="⬆"
+ [ $_ahead -gt 1 ] && git_tracking_status+="$(echo $_ahead | _subscript_number)"
fi
- fi
+ fi
echo $git_tracking_status
}
diff --git a/12_Prompts.zsh b/12_Prompts.zsh
index d49b947..48423a8 100644
--- a/12_Prompts.zsh
+++ b/12_Prompts.zsh
@@ -84,7 +84,19 @@ __update_prompt_elements()
__set_prompt_date
__hbar
- CURDIR=$C_$_prompt_colors[path]$_C"%(!.%d.%~)"$C_$color[none]$_C
+ CURDIR="%(!.%d.%~)"
+ __gitdir="$(readlink -m $( git rev-parse --git-dir 2>&- ) 2>&- | sed 's\'$HOME'\~\;s\/.git$\\')"
+ #print "#1# "$__gitdir
+ #print "#2# "$CURDIR
+ #print "#2# "$(print -Pn $CURDIR)
+ if [ -n "$__gitdir" ]
+ then
+ ___gitdir=$(dirname $__gitdir)"/"
+ [ $___gitdir == "./" ] && unset ___gitdir
+ CURDIR="$(print -Pn "$CURDIR" | sed "s*$__gitdir*$___gitdir${C_}$_prompt_colors[soft_generic];3$_C${__gitdir:t}$C_$_prompt_colors[path]$_C*")"
+ fi
+ #print "#3# "$CURDIR
+ CURDIR=$C_$_prompt_colors[path]$_C$CURDIR$C_$color[none]$_C
}
diff --git a/net:foret/Prompts.zsh b/net:foret/Prompts.zsh
index d93120d..85c30f4 100644
--- a/net:foret/Prompts.zsh
+++ b/net:foret/Prompts.zsh
@@ -46,7 +46,7 @@ __compilation_target ()
[ -n "$TARGET" ] || return
echo -n $C_
export | grep -q '^TARGET=' && echo -n "1;"
- echo -n $_make_colors[target]$_C$TARGET
+ echo -n $_make_colors[target]$_C$(echo $TARGET | sed 's/-\([A-Z]\)[A-Z]\+/-\1/g')
}
__verbose_compilation ()
diff --git a/net:foret/user:hiegel/Hashes.zsh b/net:foret/user:hiegel/Hashes.zsh
index 8f564ca..fc58d3c 100644
--- a/net:foret/user:hiegel/Hashes.zsh
+++ b/net:foret/user:hiegel/Hashes.zsh
@@ -1,4 +1,5 @@
hash -d work=/work/$USER
hash -d share=/share/public/hugues
+hash -d hugues=/home/hugues