config

A simple configuration manager

Commit
572d913ce8963122e85555da3977a954d229ed00
Parent
bcf58c5330679d623eb1891de8a25dadc7b1b5ef
Author
Pablo <pablo-escobar@riseup.net>
Date

Added functionality to color the output of the 'status' command

Also made it so that deleted/modified files aren't printed if there isn't any

Diffstat

1 file changed, 15 insertions, 9 deletions

Status File Name N° Changes Insertions Deletions
Modified config 24 15 9
diff --git a/config b/config
@@ -121,15 +121,21 @@ case "$1" in
     config_git_status="$(mktemp)"
     call_git status > "$config_git_status"
 
-    echo 'modified files:'
-    awk '/modified/ { print $2 }' "$config_git_status" \
-      | xargs -r realpath \
-      | xargs -r -n 1 printf '    %s\n'
-
-    echo 'deleted files:'
-    awk '/deleted/ { print $2 }' "$config_git_status" \
-      | xargs -r realpath \
-      | xargs -r -n 1 printf '    %s\n'
+    if grep modified "$config_git_status" > /dev/null;
+    then
+      printf '\033[0;33mmodified files:\n'
+      awk '/modified/ { print $2 }' "$config_git_status" \
+        | xargs -r realpath \
+        | xargs -r -n 1 printf '    %s\033[0m\n'
+    fi
+
+    if grep deleted "$config_git_status" > /dev/null;
+    then
+      printf '\033[0;31mdeleted files:\n'
+      awk '/deleted/ { print $2 }' "$config_git_status" \
+        | xargs -r realpath \
+        | xargs -r -n 1 printf '    %s\033[0m\n'
+    fi
 
     rm "$config_git_status"
     ;;