]> git.bochard.net Git - mysite.git/commitdiff
NOW WITH COLORS!
authorbochard <mail@bochard.net>
Sun, 6 Jul 2025 04:30:39 +0000 (12:30 +0800)
committerbochard <mail@bochard.net>
Sun, 6 Jul 2025 04:30:39 +0000 (12:30 +0800)
sync-works.sh

index c49501c153f722cca08199169efe8f5faa786985..385fd31be780d60f4f271c2a64db0f9e97c0f76b 100755 (executable)
@@ -1,8 +1,14 @@
 #!/bin/bash
 
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+YELLOW='\033[0;33m'
+BLUE='\033[0;34m'
+NC='\033[0m'
+
 declare -A works
 
-echo "Reading works-list.txt file...";
+echo -e "${BLUE}Reading works-list.txt file...${NC}";
 while IFS=' ' read -r name url || [ -n "$name" ]; do
   works[$name]="$url"
 done < works-list.txt
@@ -10,27 +16,31 @@ done < works-list.txt
 worksBase='works'
 mkdir -p "$worksBase"
 
-echo "Cloning or updating repos in $worksBase..."
+echo -e "${BLUE}Cloning or updating repos in $worksBase...${NC}"
 for work in "${!works[@]}"; do
   destPath="$worksBase/$work"
 
   if [ ! -d "$destPath" ]; then
-    echo "Cloning $work to $worksBase..."
+    echo -e "${BLUE}Cloning $work to $worksBase...${NC}"
     git clone "${works[$work]}" "$destPath"
-    echo "$work cloned successfully."
+    echo -e "${GREEN}$work cloned successfully.${NC}"
   else
-    echo "$work already exists. Fetching latest changes..."
+    echo -e "${BLUE}$work already exists. Fetching latest changes...${NC}"
     branch=$(git -C "$destPath" rev-parse --abbrev-ref HEAD)
     git -C "$destPath" fetch origin
     git -C "$destPath" reset --hard "origin/$branch"
-    echo "$work updated to latest commit on $branch."
+    echo -e "${GREEN}$work updated to latest commit on $branch.${NC}"
   fi
 done
 
-echo "Staging changes in $worksBase..."
+echo -e "${BLUE}Staging changes in $worksBase...${NC}"
 git add "$worksBase/"
 
-echo "Committing changes..."
-git commit -m "Updated cloned repos in $worksBase." || echo "Nothing to commit."
+echo -e "${BLUE}Committing changes...${NC}"
+if git commit -m "Updated cloned repos in $worksBase."; then
+  echo -e "${GREEN}Changes committed.${NC}"
+else
+  echo -e "${RED}Nothing to commit.${NC}"
+fi
 
-echo "done."
\ No newline at end of file
+echo -e "${GREEN}done.${NC}"
\ No newline at end of file