dot

packages and services management
Log | Files | Refs | README

commit 7a6d1a7c2cf7c4941d48db6a3904c880f169ffb5
parent 3597a89c73207906f4c1d6ac98a79225c5fe04ff
Author: josuah <mail@josuah.net>
Date:   Tue,  1 Nov 2016 16:19:39 -0400

I need to check git output so commiting a few

Diffstat:
Mshell/.profile | 15++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/shell/.profile b/shell/.profile @@ -55,18 +55,20 @@ git_status() { git rev-parse &>/dev/null || return 0 - local branch="$(git branch)" + local branch="$(git branch)" branch_line printf %s "${branch#??}" local behind=0 ahead=0 untracked=0 conflicts=0 changed=0 staged=0 - while IFS='' read -r status + while IFS='' read -r line do + status="$(printf %s "$line" | sed -r 's/(..).*/\1/')" # thanks to magicmonty@github for this part while [ "$status" ] do case "$status" in #two fixed character matches, loop finished + '##' ) branch_line="$line" ;; '??' ) untracked="$((untracked + 1))"; break ;; U? ) conflicts="$((conflicts + 1))"; break ;; ?U ) conflicts="$((conflicts + 1))"; break ;; @@ -88,8 +90,15 @@ git_status() done done << EOF -$(git status --porcelain | sed -r 's/(..).*/\1/') +$(git status --porcelain) EOF + + if [ -z "${branch_line##*[*}" ] + then + branch_line="${branch_line#*[}" + branch_line="${branch_line%]*}" + fi + printf '\033[1m' if [ "$untracked$conflicts$changed$staged" = '0000' ]