One of the things I really miss about using a hosted, web-based blogging service like Tumblr or Posterous was the bookmarklets - a javascript bookmark that would quickly create a new post out of whatever I had highlighted. Since there’s no easy way to get from javascript to filesystem commands (even for Chrome extensions and the like), I decided to write a little script to do it for me and link it to a system-wide service. Here’s how you can use it, too.

First, in your jekyll project directory, make a file called new and copy it from this Github gist. For easy mode: download the gist here.

From the command line in your project directory, you can call it with a title, image, or link, like so: ./new "A new post title". The script will figure it out, make a new page out of it, and open it in TextMate.

To call that from anywhere, we’ll need a service. Pop open Automator and select “Service” from the dialogue that comes up, like so:

New Service

Then, choose “get selected text” and send it to the “run a script” action, pointing it to your new script, like so:

Jekyll Service

Save the service as something appropriate. I called mine “New Github Page”.

To make this even easier, add a keyboard shortcut for your new service. Go to the “Keyboard Shortcuts” preference pane, select “Services” and find the service you just made in automator. Double-click to the right of the service name, and choose a good global hotkey. I chose CMD+ALT+G, since “command alt Github” is easy for me to remember.

Jekyll Keyboard Shortcut

Now, from any page, you can select the url (hopefully with CMD+L or some other shortcut) and hit your “new page” key, and it will make a new markdown file with the page’s Title and a custom permalink, and whatever default layout you want. Or select an image and quickly get the image downloaded and linked in.

It’s super easy. If you have any suggested improvements, feel free to fork / edit the Github gist, leave comments, etc. Hope this helps somebody!