ref: 039fb2ad3872fb18231e04fb8fa55c15065da3fd
parent: 43eb744fa3594234b01dbf41837489f6224f4e99
author: Halfwit <michaelmisch1985@gmail.com>
date: Sat Mar 25 15:02:15 PDT 2017
Changing around to do less on invocation
--- a/gitbar
+++ b/gitbar
@@ -2,15 +2,30 @@
GITBAR="$XDG_RUNTIME_DIR/statusbar/git"
-commit=`commit wc`
-push=`push wc`
-pull=`pull wc`
+comm=0
+push=0
+pull=0
+
+while IFS="⇄↑↓" read -r input; do
+ case $input in
+ *⇄*) comm=`echo $input | tr -cd [:digit:]` ;;
+ *↑*) push=`echo $input | tr -cd [:digit:]` ;;
+ *↓*) pull=`echo $input | tr -cd [:digit:]` ;;
+ esac
+done < $GITBAR
+
+case $1 in
+ commit) comm=`commit wc` ;;
+ pull) pull=`pull wc` ;;
+ push) push=`push wc` ;;
+esac
+
check=0
-if [ $commit -gt 0 ]; then
- commit="⇄$commit"
+if [ $comm -gt 0 ]; then
+ comm="⇄$comm"
check=1
else
- commit=""
+ comm=""
fi
if [ $push -gt 0 ]; then
@@ -28,7 +43,7 @@
fi
if [ $check -eq 1 ]; then
- printf '%s\n' " [$commit$push$pull]" > "$GITBAR"
+ printf '%s\n' " [$push$pull$comm]" > "$GITBAR"
else
printf '%s\n' "" > "$GITBAR"
fi