From b110ba12b29391c5530b179f540adb6b15ed6f80 Mon Sep 17 00:00:00 2001 From: poulpe <poulpe@localhost.localdomain> Date: Thu, 29 Oct 2020 20:41:34 +0100 Subject: [PATCH] [Features + Bug] Add global variable for color + Fix error for .gitignore by overwrite file --- gitcreate.sh | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/gitcreate.sh b/gitcreate.sh index a6abc9a..13deff6 100755 --- a/gitcreate.sh +++ b/gitcreate.sh @@ -8,11 +8,17 @@ ACCESS_TOKEN="" HTTPS="https://gitedu.hesge.ch" SSH="ssh://git@ssh.hesge.ch:10572" +# Add global var for color +GREEN="\e[32m" +RESET="\e[0m" +BROWN="\e[33m" +RED="\e[31m" + # messages -GITIGNORE_GENERATED="\e[32m.gitignore generated.\e[0m" -REPOSITORY_NAME_TAKEN="\e[33mA repository with this name already exists.\e[0m" -ARGUMENTS_MISSING="\e[31mArguments are missing.\e[0m" -REPOSITORY_CREATED="\e[32mThe repository is now created with the files of the current folder pushed to it.\e[0m" +GITIGNORE_GENERATED= "${GREEN}.gitignore generated.${RESET}" +REPOSITORY_NAME_TAKEN= "${BROWN}A repository with this name already exists.${RESET}" +ARGUMENTS_MISSING= "${RED}Arguments are missing.${RESET}" +REPOSITORY_CREATED= "${GREEN}The repository is now created with the files of the current folder pushed to it.${RESET}" # Display the usage of the script function d_usage { @@ -43,7 +49,7 @@ do p) PUBLIC=${OPTARG};; m) METHOD=${OPTARG};; \?) - echo -e "\e[31m-${OPTARG} is not a valid option.\e[0m" + echo -e "${RED}-${OPTARG} is not a valid option.${RESET}" d_usage exit;; esac @@ -89,9 +95,9 @@ fi # Create a .gitignore specific to a c program touch .gitignore echo "*" > .gitignore -echo "!*.*" > .gitignore -echo "!Makefile" > .gitignore -echo "*.o" > .gitignore +echo "!*.*" >> .gitignore +echo "!Makefile" >> .gitignore +echo "*.o" >> .gitignore # Initialize a local repository and push the files @@ -102,4 +108,4 @@ git commit -m "initial commit" git push -u origin master echo -e $GITIGNORE_GENERATED -echo -e $REPOSITORY_CREATED \ No newline at end of file +echo -e $REPOSITORY_CREATED -- GitLab