Skip to content

Instantly share code, notes, and snippets.

@dansheffler
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dansheffler/cabc4ad0ea35b7ebe874 to your computer and use it in GitHub Desktop.
Save dansheffler/cabc4ad0ea35b7ebe874 to your computer and use it in GitHub Desktop.
Quick and dirty Sublime Text 3 plugin to create a new Jekyll post.
import sublime, sublime_plugin, time
class MyJekyllCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.window().show_input_panel("Name of New Post", "", self.create_post, None, None)
def create_post(self, theTitle):
date = time.strftime("%Y-%m-%d-")
safeTitle = date + theTitle.lower().replace(" ","-")
path = "/Users/dansheffler/Dropbox/dansheffler/_posts/" + safeTitle + ".md"
newFile = open(path, "w")
newFile.write("---\nTitle: " + theTitle + "\n---\n\n")
newFile.close()
self.view.window().open_file(path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment