Last active
January 8, 2017 17:07
-
-
Save kevinquillen/307f9ec2f6e2b685c64f1bc6ce2b745c to your computer and use it in GitHub Desktop.
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