Skip to content

Instantly share code, notes, and snippets.

@balos1
Created July 25, 2017 03:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save balos1/396c10e8c57093f587bfc3f6450ea1e7 to your computer and use it in GitHub Desktop.
Save balos1/396c10e8c57093f587bfc3f6450ea1e7 to your computer and use it in GitHub Desktop.
#!/bin/bash
# console colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
# project name comes top folder name by default
PROJECT=$(basename $PWD)
# get user input
echo -e -n "${YELLOW}Project [$PROJECT]${NC}: "
read -p "" PROJECT1
SCHOOL=${PROJECT1:-$PROJECT}
echo -e -n "${YELLOW}School [$HOMEWORK_SCHOOL_NAME]${NC}: "
read -p "" SCHOOL
SCHOOL=${SCHOOL:-$HOMEWORK_SCHOOL_NAME}
echo -e -n "${YELLOW}Course Title [$PROJECT]${NC}: "
read -p "" TITLE
TITLE=${TITLE:-$PROJECT}
echo -e -n "${YELLOW}Semester${NC}: "
read -p "" SEMESTER
echo -e -n "${YELLOW}Professor${NC}: "
read -p "" PROFESSOR
echo -e -n "${YELLOW}Your Name [$HOMEWORK_NAME]${NC}: "
read -p "" NAME
NAME=${NAME:-$HOMEWORK_NAME}
# create macro file for project
echo "\ProvidesPackage{$PROJECT}[$(date +%Y/%m/%d) v1.0 Macros for $PROJECT]" > $PROJECT.sty
echo "
\RequirePackage{homework}
\newcommand{\hmwkClass}{$TITLE}
\newcommand{\hmwkSemester}{$SEMESTER}
\newcommand{\hmwkSchool}{$SCHOOL}
\newcommand{\hmwkClassInstructor}{$PROFESSOR}
\newcommand{\hmwkAuthorName}{\textbf{$NAME}}" >> $PROJECT.sty
echo -e "${GREEN}Created macros file for course. Include it by adding \usepackage{$PROJECT.sty} to each homework file.${NC}"
# get homework.sty and a good gitignore for the project, then init repo.
wget --quiet https://gist.githubusercontent.com/cojomojo/3e364dccded3b75c4cad5e8c8f898958/raw/1c0a732b73dc9c67563fccd6d2262db4a3d421b8/homework.sty -O homework.sty
wget --quiet https://gist.githubusercontent.com/cojomojo/c8b53ca652b2e8e227a7958d9e64a35e/raw/3c543a9da6852547d224e90426c8dbbc9c4183b0/latex-homework-gitignore -O .gitignore
git init > /dev/null
git add --all > /dev/null
git commit -m "Initialized repository with new-late-homework.sh." > /dev/null
echo -e "${GREEN}Successfully initialized project.${NC}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment