Skip to content

Instantly share code, notes, and snippets.

@pala pala/newpost.rb
Last active Dec 19, 2015

Embed
What would you like to do?
to generate a new Jekyll post
#!/usr/bin/env ruby
unless ARGV[0]
puts 'Usage: newpost "the post title"'
exit(-1)
end
date_prefix = Time.now.strftime("%Y-%m-%d")
postname = ARGV[0].strip.downcase.gsub(/ /, '-')
post = "./_posts/#{date_prefix}-#{postname}.md"
header = <<-END
---
layout: post
title: #{ARGV[0]}
categories:
tags:
---
END
File.open(post, 'w') do |f|
f << header
end
system("open", post)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.