-
-
Save jrk/106869 to your computer and use it in GitHub Desktop.
Creates a new Jekyll post, opens it in TextMate, and adds to the git index
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require Dir | |
unless ARGV[0] | |
puts 'Usage: newpost "the post title"' | |
exit(-1) | |
end | |
blog_root = "/Users/jrk/proj/blog" | |
date_prefix = Time.now.strftime("%Y-%m-%d") | |
postname = ARGV[0].strip.downcase.gsub(/ /, '-') | |
post = "#{blog_root}/_posts/#{date_prefix}-#{postname}.md" | |
header = <<-END | |
--- | |
layout: post | |
title: "#{ARGV[0]}" | |
--- | |
END | |
Dir.chdir(blog_root) | |
File.open(post, 'w') do |f| | |
f << header | |
end | |
system("mate", "-w", post) | |
system("git", "add", post) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment