Skip to content

Instantly share code, notes, and snippets.

@TravisL12
Created February 7, 2020 17:36
Show Gist options
  • Save TravisL12/233fd442a2b8362d82b89e6dd3a69c19 to your computer and use it in GitHub Desktop.
Save TravisL12/233fd442a2b8362d82b89e6dd3a69c19 to your computer and use it in GitHub Desktop.
Generate simple HTML/CSS/JS folder structure
#!/bin/bash
NEW_DIR=$1 # define folder/project name as command line argument
if [[ -z $NEW_DIR ]]; then # if no CLI argument provided then prompt for project name
echo "Give a directory name to create:"
read NEW_DIR
fi
ORIG_DIR=$(pwd)
[[ -d $NEW_DIR ]] && echo $NEW_DIR already exists, aborting && exit
mkdir $NEW_DIR # make directory
cd $NEW_DIR # enter directory
pwd # print name of directory
touch index.html
echo "<html lang='en'>
<head>
<meta charset='UTF-8' />
<meta name='viewport' content='width=device-width, initial-scale=1.0' />
<link rel='stylesheet' href='public/styles/styles.css' />
<title>$NEW_DIR</title>
</head>
<body>Welcome to the \"$NEW_DIR\" project</body>
<script src='public/scripts/application.js'></script>
</html>" >>index.html
mkdir public
cd public
mkdir -p scripts styles
touch scripts/application.js styles/styles.css
open $ORIG_DIR/$NEW_DIR
echo "Goodbye"
# original script https://askubuntu.com/questions/952582/bash-script-to-create-a-directory
# symlink https://askubuntu.com/questions/427818/how-to-run-scripts-without-typing-the-full-path
# ln -s /full/path/to/your/file /usr/local/bin/name_of_new_command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment