-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_project.sh
executable file
·49 lines (42 loc) · 1.21 KB
/
create_project.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
# Prompt for the name of the new folder
echo "Please enter the name for the new folder:"
read FOLDER_NAME
# Define the destination path
DESTINATION_PATH="../../Projects/${FOLDER_NAME}"
# Create the new folder
mkdir -p "$DESTINATION_PATH" &> /dev/null
if [ $? -eq 0 ]; then
echo "Directory created successfully."
else
echo "Failed to create directory."
exit 1
fi
# Copy all files and folders except the specified ones
rsync -av --progress . "$DESTINATION_PATH" --exclude .git --exclude create_project.sh --exclude-from=.gitignore &> /dev/null
if [ $? -eq 0 ]; then
echo "All files copied successfully."
else
echo "Failed to copy files."
exit 1
fi
# Initialize a new git repository and make the first commit
cd "$DESTINATION_PATH"
git init &> /dev/null
git add . &> /dev/null
git commit -m "Initial commit" &> /dev/null
if [ $? -eq 0 ]; then
echo "Git repository initialized and first commit made."
else
echo "Failed to initialize git repository."
exit 1
fi
# Open the new folder in Visual Studio Code
code .
if [ $? -eq 0 ]; then
echo "Visual Studio Code opened successfully."
else
echo "Failed to open Visual Studio Code."
exit 1
fi
echo "Process completed successfully."