Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 28 lines (21 sloc) 457 Bytes
#!/usr/bin/env ruby
unless ARGV[0]
puts 'Usage: newpost "the post title"'
exit(-1)
end
date_prefix = Time.now.strftime("%Y-%m-%d")
post_name = ARGV.join ' '
post_file_name = post_name.strip.downcase.gsub(/ /, '-')
post = "_posts/#{date_prefix}-#{post_file_name}.md"
header = <<-END
---
layout: post
tags:
title: #{post_name}
---
Write the "#{post_name}" content here...
END
File.open(post, 'w') do |f|
f << header
end
system("subl", "-a", post)