Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- unless ARGV[0]
- puts 'Usage: newdraft "the draft 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}.draft.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("vim #{post}")
- exit(0)
Add Comment
Please, Sign In to add comment