Last active
February 20, 2016 17:55
-
-
Save jblakeman/0651b3a3495495b478f4 to your computer and use it in GitHub Desktop.
HTML Boilerplate Generator
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
# Output HTML boilerplate code to a file name specified by the first argument | |
# If no arguments are provided, outputs to index.html | |
# example: | |
# html_boilerplate example.html | |
html_boilerplate() { | |
[[ $1 ]] || { | |
echo "usage: $FUNCNAME outfile" | |
return 1; | |
} | |
local name="$1" | |
if [[ $name ]]; then | |
[[ $name != *.html ]] && name+=.html | |
fi | |
[[ -f $name ]] && { | |
echo "error: $name currently exists as a file." | |
return 1; | |
} | |
cat << EOF > "$name" | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
</head> | |
<body> | |
</body> | |
</html> | |
EOF | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment