Custom bash function to generate a new markdown file for Jekyll, first arg is assumed to be post title, which becomes the filename in the format Jekyll is expecting. Auto open and save in Vim, if the post doesn't exist.
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
function new_post() { | |
cd ~/Sites/kevinquillen.com/_posts | |
today=$(date +"%F") | |
title=$1:l | |
clean_title=${title//[^a-zA-Z0-9]/-} | |
filename="$today-$clean_title.markdown" | |
if [[ ! -a ./$filename ]]; then | |
vim $filename -c 'w' | |
else | |
echo "File $filename already exists. Aborting." | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment