Skip to content

Instantly share code, notes, and snippets.

@joshkerr
Created April 6, 2011 16:13
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 joshkerr/905952 to your computer and use it in GitHub Desktop.
Save joshkerr/905952 to your computer and use it in GitHub Desktop.
This is a quick script to create a new post in Jekyll
# create a new post and fill the template
alias create="sh ~/.postname"
# the contents of ~/.postname:
#!/bin/zsh
################
# Get our info #
################
yearmonth=`date "+%Y/%m"`
postdate=`date "+%Y-%m-%d"`
jekylldate=`date "+%Y-%m-%d"`
read -p "Enter the post name: " post_variable;
touch /Users/TJ/Desktop/foobar.com/_posts/$yearmonth/$postdate-$post_variable.markdown &&
cat <<EOF > /Users/TJ/Desktop/foobar.com/_posts/$yearmonth/$postdate-$post_variable.markdown
---
layout: post
date: $jekylldate
title: $post_variable
excerpt:
---
EOF
mate /Users/TJ/Desktop/foobar.com/_posts/$yearmonth/$postdate-$post_variable.markdown
exit 0
# start up Jekyll for local preview of blog
alias preview="cd /Users/TJ/Desktop/foobar.com && jekyll --server --auto"
# delete the existing built site and rebuild
alias build="cd /Users/TJ/Desktop/foobar.com && rm -rf _site/ && jekyll"
# use rsync to push the weblog to my (ve)
alias deploy="echo 'Deploying to remote host...' &&
cd /Users/TJ/Desktop/foobar.com && rsync -rtz --delete _site/ deploy@foobar.com:/var/www/_site &&
echo 'Done!'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment