From 8508284ae9c03c544397238f5950b7a666fd353d Mon Sep 17 00:00:00 2001 From: ION606 Date: Wed, 26 Jun 2024 13:11:19 -0400 Subject: [PATCH] added colors --- README.md | 2 +- clone.sh | 5 +++-- getuser.sh | 2 +- init.sh | 5 +++-- login.sh | 2 +- push.sh | 6 +++--- run.sh | 25 ++++++++++++++----------- status.sh | 4 ++-- 8 files changed, 28 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 0d24111..185c1f0 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ A future version control system and file sharing system built over rsync and ins ## Running ## Option 1: The Script -just use `curl -fsSL -o ivcs.sh https://github.com/ION606/VCS/raw/main/init.sh && chmod +x ivcs.sh && sudo ./ivcs.sh` +just use `curl -fsSL -o ivcs.sh https://github.com/ION606/VCS/raw/main/init.sh && chmod +x ivcs.sh && ./ivcs.sh` ## Option 2: Maually diff --git a/clone.sh b/clone.sh index 1e9f226..64e2207 100644 --- a/clone.sh +++ b/clone.sh @@ -6,7 +6,7 @@ mkdir -p .ionvcs # Check if a path is provided as an argument if [ -z "$1" ]; then - echo "please provide a path to clone (like ~/Desktop/code_here)" + echo -e "\e[31mERROR!\e[0m please provide a path to clone (like \e[34m~/Desktop/code_here\e[0m)" exit 1 fi @@ -20,11 +20,12 @@ fi # Create the destination folder if it doesn't exist mkdir -p "$DEST_FOLDER" + # Source the credentials file if it exists if [ -f "$HOME/ionsrc/creds.txt" ]; then source "$HOME/ionsrc/creds.txt" else - echo "credentials file not found! (please use the login command)" + echo -e "\e[31mcredentials file not found!\e[0m (please use the \e[0;32mlogin\e[0m command)" exit 1 fi diff --git a/getuser.sh b/getuser.sh index 030cce4..960e4c9 100644 --- a/getuser.sh +++ b/getuser.sh @@ -2,7 +2,7 @@ if [ -f "$HOME/ionsrc/creds.txt" ]; then source "$HOME/ionsrc/creds.txt" - echo "logged in as $username!" + echo "logged in as \033[0;31m$username\e[0m!" else echo "no user found!" fi \ No newline at end of file diff --git a/init.sh b/init.sh index 9787796..cfd82dc 100644 --- a/init.sh +++ b/init.sh @@ -7,7 +7,7 @@ if ! command -v sshpass &> /dev/null || ! command -v pv &> /dev/null || ! comman elif command -v apt-get &> /dev/null; then sudo apt-get -y install sshpass pv git else - echo "Package manager not found. Please install sshpass, pv, and git manually" + echo -e "\e[31mPackage manager not found. Please install sshpass, pv, and git manually\e[0m" exit 1 fi fi @@ -16,9 +16,10 @@ fi git clone https://github.com/ION606/VCS.git .ionvcs # Move files -sudo mv .ionvcs/ionsrc.desktop /usr/share/applications/ionsrc.desktop || echo "FAILED TO MOVE DESKTOP FILE" +sudo mv .ionvcs/ionsrc.desktop /usr/share/applications/ionsrc.desktop || echo -e "\e[31mFAILED TO MOVE DESKTOP FILE\e[0m" mkdir -p ~/ionsrc mv .ionvcs/* ~/ionsrc/ +echo "alias ionvcs='bash ~/ionsrc/run.sh'" >> ~/.bashrc # Clean up rm -rf .ionvcs diff --git a/login.sh b/login.sh index 984b989..5513036 100644 --- a/login.sh +++ b/login.sh @@ -15,5 +15,5 @@ echo "password=$password" >> "$CREDSFILE"; # Secure the file chmod 600 "$CREDSFILE"; -echo "Logged in!"; +echo "Logged in as \033[0;31m$username\e[0m!"; exit; \ No newline at end of file diff --git a/push.sh b/push.sh index fc8b333..ee83211 100644 --- a/push.sh +++ b/push.sh @@ -4,10 +4,10 @@ cd "$PWD" if [ ! -f "$HOME/ionsrc/creds.txt" ]; then - echo "credentials file not found!" + echo -e "\e[31mcredentials file not found!\e[0m" exit 1 elif [ ! -f "$PWD/.ionvcs/src.config"]; then - echo "config file not found!" + echo -e "\e[31mconfig file not found!\e[0m" exit 1 fi @@ -38,7 +38,7 @@ DIFF_OUTPUT=$(/usr/bin/sshpass -p "$password" rsync -avcn --delete -e ssh "$REMO # Check if there are differences if [ ! -z "$DIFF_OUTPUT" && ! $force_flag ]; then - echo "conflicts found between the local and remote directories (make sure they're correct and re-run using the -f flag):" + echo -e "\e[31mERROR\e[0m conflicts found between the local and remote directories (make sure they're correct and re-run using the \e[31m-f\e[0m flag):" echo "$DIFF_OUTPUT" exit 1; fi diff --git a/run.sh b/run.sh index 1c5d1f8..b52d736 100644 --- a/run.sh +++ b/run.sh @@ -5,30 +5,33 @@ shift; case $COMMAND in "clone") - bash clone.sh "$@" + bash $HOME/ionsrc/clone.sh "$@" ;; - + "push") - bash push.sh "$@" + bash $HOME/ionsrc/push.sh "$@" ;; - + "login") - bash login.sh "$@" + bash $HOME/ionsrc/login.sh "$@" ;; - + "user") - bash getuser.sh + bash $HOME/ionsrc/getuser.sh ;; "status") - bash status.sh + bash $HOME/ionsrc/status.sh ;; - + "help") - bash help.sh + bash $HOME/ionsrc/help.sh ;; *) - echo "UNKNOWN COMMAND \"$@\"" + echo "UNKNOWN COMMAND \"$COMMAND\"" + GREEN='\033[0;31m' + NC='\033[0m' # No Color + echo -e "use ${GREEN}\`ionvcs help\`${NC} for help" ;; esac \ No newline at end of file diff --git a/status.sh b/status.sh index f78c2b0..d853f34 100644 --- a/status.sh +++ b/status.sh @@ -4,10 +4,10 @@ cd "$PWD" if [ ! -f "$HOME/ionsrc/creds.txt" ]; then - echo "credentials file not found!" + echo -e "\e[31mcredentials file not found!\e[0m" exit 1 elif [ ! -f "$PWD/.ionvcs/src.config"]; then - echo "config file not found!" + echo -e "\e[31mconfig file not found!\e[0m" exit 1 fi