Skip to content

Instantly share code, notes, and snippets.

@zigzag
Forked from al3x/newpost.rb
Created December 12, 2009 13:38
Show Gist options
  • Save zigzag/254887 to your computer and use it in GitHub Desktop.
Save zigzag/254887 to your computer and use it in GitHub Desktop.
New post command shell for Jekyll
#!/usr/bin/ruby
unless ARGV[0]
puts 'Usage: np "the post title"'
exit(-1)
end
title = ARGV.join ' '
date_prefix = Time.now.strftime("%Y-%m-%d")
postname = title.strip.downcase.gsub(/ /, '-')
post = "./_posts/#{date_prefix}-#{postname}.textile"
header = <<-END
---
layout: post
title: #{title}
---
h1. {{ page.title }}
p(meta). #{Time.now.strftime '%d %b %Y'} - Beijing
END
File.open(post, 'w') { |f| f << header }
system("mate", "-a", post)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment