Parcourir la source

short repos status added to giti

84582af
Dirk Alders il y a 2 ans
Parent
révision
fcfcf72c41
1 fichiers modifiés avec 38 ajouts et 17 suppressions
  1. 38
    17
      giti

+ 38
- 17
giti Voir le fichier

@@ -5,6 +5,7 @@ while getopts "hnrs" options; do
5 5
   case $options in
6 6
     n ) NO_DETAILS="True";;
7 7
     r ) REPEAT="True";;
8
+    s ) SHORT="True";;
8 9
     h ) echo $usage
9 10
         exit 0
10 11
         ;;
@@ -29,24 +30,44 @@ else
29 30
     git_status="$(LANGUAGE='en_US.UTF-8 git' git status 2> /dev/null)"
30 31
     git_diff="$(git  status --porcelain 2> /dev/null)"
31 32
     #
32
-    if [[ ! $git_status = "" ]]; then
33
-    git_branch="$(git branch 2> /dev/null | sed --quiet 's/* \(.*\)/\1/p')"
34
-    git_url="$(git config --get remote.origin.url 2> /dev/null)"
35
-    if [[ ! $git_status =~ "working tree clean" ]] && [[ ! $git_status =~ "working directory clean" ]]; then
36
-      git_status_color="$COLOR_RED"
37
-      git_status_text="╡ local changes ╞"
38
-    elif [[ $git_status =~ "Your branch is behind" ]]; then
39
-      git_status_color="$COLOR_YELLOW"
40
-      git_status_text="╡ pull required ╞"
41
-    elif [[ $git_status =~ "Your branch is ahead of" ]]; then
42
-      git_status_color="$COLOR_YELLOW"
43
-      git_status_text="╡ push required ╞"
44
-    elif [[ $git_status =~ "nothing to commit" ]]; then
45
-      git_status_color="$COLOR_DARKGREEN"
46
-      git_status_text="╡ clean ╞════════"
33
+    if [[ $SHORT ]]; then
34
+      if [[ ! $git_status =~ "working tree clean" ]] && [[ ! $git_status =~ "working directory clean" ]]; then
35
+        git_status_color="$COLOR_RED"
36
+        git_status_text="local changes"
37
+      elif [[ $git_status =~ "Your branch is behind" ]]; then
38
+        git_status_color="$COLOR_YELLOW"
39
+        git_status_text="pull required"
40
+      elif [[ $git_status =~ "Your branch is ahead of" ]]; then
41
+        git_status_color="$COLOR_YELLOW"
42
+        git_status_text="push required"
43
+      elif [[ $git_status =~ "nothing to commit" ]]; then
44
+        git_status_color="$COLOR_DARKGREEN"
45
+        git_status_text="clean        "
46
+      else
47
+        git_status_color="$COLOR_OCHRE"
48
+        git_status_text="unknown      "
49
+      fi
50
+      echo -ne "$git_status_color$git_status_text$COLOR_WHITE"
47 51
     else
48
-      git_status_color="$COLOR_OCHRE"
49
-      git_status_text="╡ unknown ╞══════"
52
+      if [[ ! $git_status = "" ]]; then
53
+      git_branch="$(git branch 2> /dev/null | sed --quiet 's/* \(.*\)/\1/p')"
54
+      git_url="$(git config --get remote.origin.url 2> /dev/null)"
55
+      if [[ ! $git_status =~ "working tree clean" ]] && [[ ! $git_status =~ "working directory clean" ]]; then
56
+        git_status_color="$COLOR_RED"
57
+        git_status_text="╡ local changes ╞"
58
+      elif [[ $git_status =~ "Your branch is behind" ]]; then
59
+        git_status_color="$COLOR_YELLOW"
60
+        git_status_text="╡ pull required ╞"
61
+      elif [[ $git_status =~ "Your branch is ahead of" ]]; then
62
+        git_status_color="$COLOR_YELLOW"
63
+        git_status_text="╡ push required ╞"
64
+      elif [[ $git_status =~ "nothing to commit" ]]; then
65
+        git_status_color="$COLOR_DARKGREEN"
66
+        git_status_text="╡ clean ╞════════"
67
+      else
68
+        git_status_color="$COLOR_OCHRE"
69
+        git_status_text="╡ unknown ╞══════"
70
+      fi
50 71
     fi
51 72
 
52 73
     echo -e "$git_status_color╔═══$git_status_text════════════════════════════════════════════════════════════════"

Chargement…
Annuler
Enregistrer