Last active
January 23, 2018 12:17
-
-
Save Phlow/59625dc4afd85560ed667f8423958b64 to your computer and use it in GitHub Desktop.
Ask for a title and create a post for Jekyll in _posts and open in in your favorite editor
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
#!/bin/bash | |
# | |
# Create a post for Jekyll | |
# Configuration | |
EDITOR='Atom' | |
DATE=`date +%Y-%m-%d` | |
DOCFORMAT='md' # Without Point (!) | |
DIRECTORY='./_posts/' | |
# Get Input | |
clear | |
echo -e "\n" | |
read -p $'Title › ' TITLE | |
# Convert URL | |
TITLE_NO_HYPHENS=${TITLE// /-} # convert spaces in title to hyphens | |
TITLE_NO_HYPHENS_LOWERCASE=`echo "$TITLE_NO_HYPHENS" | tr '[:upper:]' '[:lower:]'` # convert title to lowercase | |
PERMALINK=${DATE}-${TITLE_NO_HYPHENS_LOWERCASE}.${DOCFORMAT} | |
FILE=$DIRECTORY/$PERMALINK | |
# Show content | |
echo -e "\n--- | |
title : $TITLE | |
permalink : /$TITLE_NO_HYPHENS_LOWERCASE/ | |
# meta_description : | |
---" | |
echo -e "\nCreate $PERMALINK in $DIRECTORY?\n" | |
select yn in "Yes" "No"; do | |
case $yn in | |
Yes ) break;; | |
No ) echo "\nAbort mission";exit;; | |
esac | |
done | |
# Create file | |
touch $FILE | |
# Write content into new posting | |
echo "--- | |
title : $TITLE | |
permalink : /$TITLE_NO_HYPHENS_LOWERCASE/ | |
# meta_description : | |
---" > $FILE | |
open $FILE -a "$EDITOR" |
@freefallcid Thank you for your comment. Just saw it today. Got no notification. Stumbled across it by chance and edited the gist. Thanks again!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You forgot that you declared a variable to use any editor. 😃