Skip to content

Instantly share code, notes, and snippets.

@markoa
Created May 19, 2010 11:30
Show Gist options
  • Save markoa/406206 to your computer and use it in GitHub Desktop.
Save markoa/406206 to your computer and use it in GitHub Desktop.
Creates a blank textile file with basic YAML front matter for a Jekyll blog, launches editor.
#!/usr/bin/env ruby
# Creates a blank textile file with basic YAML front matter for
# your Jekyll blog. Then it launches gvim so that you can start
# writing immediately.
#
# Assumes your posts are in ./blog/_posts and that you're using a layout
# called 'post'.
if ARGV.empty?
puts "As an argument, write your new post's title. Eg 'newpost Something I want to share'."
exit
end
title = ARGV.join(" ")
slug = title.gsub(/\s+/, '-').downcase
path = "blog/_posts/#{Time.now.strftime("%Y-%m-%d")}-#{slug}.textile"
File.open(path, "w") do |f|
f.write "---\n"
f.write "title: #{title}\n"
f.write "layout: post\n"
f.write "---\n\n"
end
puts "=> #{path}"
`gvim #{path}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment