diff options
-rw-r--r-- | 01_Internal.zsh | 93 | ||||
-rw-r--r-- | net:foret/completion/_endurance | 8 |
2 files changed, 51 insertions, 50 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/net:foret/completion/_endurance b/net:foret/completion/_endurance index b37a266..1af5d51 100644 --- a/net:foret/completion/_endurance +++ b/net:foret/completion/_endurance @@ -18,9 +18,11 @@ _endurance() { case "$service" in do.sh) _arguments \ - ':actions:(( $(list-commands) ))' \ - ':tests:(( $(list-tests) ))' \ - ':nodes:(( $(list-nodes) ))' + ':actions:(( $(list-commands) ))' \ + ':tests:(( $(list-tests) ))' \ + ':nodes:(( $(list-nodes) ))' + _alternative \ + '*:files: _files' ;; esac |