fabianmoronzirfas
5/23/2017 - 4:58 AM

Handy new post script for Jekyll blogs or similar

Handy new post script for Jekyll blogs or similar

#!/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 = "/Users/al3x/src/al3x.github.com/_posts/#{date_prefix}-#{postname}.textile"

header = <<-END
---
layout: post
title: "#{ARGV[0]}"
---

h1. {{ page.title }}

END

File.open(post, 'w') do |f|
  f << header
end

system("mate", "-a", post)