-
-
Save mrchrisadams/258386 to your computer and use it in GitHub Desktop.
This file contains 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 | |
unless ARGV[0] | |
puts 'Usage: newpost "the post title"' | |
exit(-1) | |
end | |
# set the date for the entry, where the jekyll blog is and process the title to give a filename: | |
date_prefix = Time.now.strftime("%Y-%m-%d") | |
postname = ARGV[0].strip.downcase.gsub(/ /, '-') | |
jekyll_path = '/Users/chrisadams/GitRepos/camuk' | |
# then construct the full path | |
post = "#{jekyll_path}/#{date_prefix}-#{postname}.markdown" | |
# set basic meta data | |
header = <<-END | |
--- | |
layout: post | |
title: "#{ARGV[0]}" | |
--- | |
# {{ page.title }} | |
END | |
File.open(post, 'w') do |f| | |
f << header | |
end | |
# finally, open the newly created file in Textmate for editing fun | |
system("mate", "-a", post) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment