Skip to content

Instantly share code, notes, and snippets.

@pala
Last active December 19, 2015 22:18
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 pala/6026435 to your computer and use it in GitHub Desktop.
Save pala/6026435 to your computer and use it in GitHub Desktop.
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