Skip to content

Instantly share code, notes, and snippets.

@maguay
Created April 3, 2013 07:39
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 maguay/5299154 to your computer and use it in GitHub Desktop.
Save maguay/5299154 to your computer and use it in GitHub Desktop.
Bash script for creating new Kirby posts via Alfred. Fork from http://plausiblethought.net/creating-new-blog-posts-with-an-alfred-workflow. Don't escape spaces. See full Alfred 2 Workflow at https://github.com/maguay/Alfred-New-Kirby-Blog-Post.
/* navigate to blog folder */
cd ~/your_site_folder/content/your_blog_folder/
/* count files */
COUNT=$(ls | wc -l)
/* remove feed folder from count */
NEWCOUNT=$(expr $COUNT - 1)
/* replace spaces in query with dashes for folder name */
DNAME=$(echo {query} | tr " " "-")
/* make folder */
mkdir $NEWCOUNT-$DNAME
/* change directory */
cd $NEWCOUNT-$DNAME
/* get date */
DATE=`date "+%a, %d %b %Y %X"`
/* create a file called article.md with query as title, along with the date */
echo "Title: {query}
----
Date: $DATE
----
Text:
" > article.md
open article.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment