Skip to content
Snippets Groups Projects

[Features + Bug] Add global variable for color + Fix error for .gitignore by overwrite file

Merged fabian.troller requested to merge fabian.troller/scripts:master into master
1 file
+ 15
9
Compare changes
  • Side-by-side
  • Inline
+ 15
9
@@ -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
Loading