Created
March 17, 2019 09:30
-
-
Save luvuong-le/4113ae3d59a1b91566ea46bd40aee01f to your computer and use it in GitHub Desktop.
Shell Script for quickly creating a template from a pre-existing folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Shebang - Tells Unix the file is executed by bin/bash | |
#!/bin/bash | |
# Template path with your project setup | |
TEMPLATE_PATH="YOUR_PROJECT_PATH" | |
function createTemplate() { | |
echo "Beginning Template Creation..." | |
# Navigate into the new directory | |
cd "${1}" | |
# Copy all files from template folder into the new folder | |
cp -r "${TEMPLATE_PATH}\." "${PWD}" | |
echo "Template Successfully Created." | |
} | |
# Create a new directory from the current directory into the new folder defined by user | |
if [ -d "${PWD}/$1" ]; then | |
echo "Folder Already Exists... Skipping" | |
else | |
echo "Creating Project Folder..." | |
mkdir "${PWD}/$1" | |
fi | |
# Create the directory | |
createTemplate "${PWD}/${1}" | |
# Prevent Shell From Closing If Needed | |
# $SHELL | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment