With my Octopress instance up and working smoothly I decided I wanted to simplify the process of creating a new posting, isolating it from all the postings, and editing it. Since I have well over 1700 entries on my site each site generation is around seven minutes. Running the generation multiple times to fix typos or edit content is not efficient.
Fortunately, Octopress comes with a Rake task called isolate, which parks all other postings in to a _stash directory so you can work on the current one in, well, isolation. Once the posting is completed, there is an integrate task that returns all the postings to the main _posts directory.
There were three activities I wanted my new post script to accomplish:
Create a new posting using the title passed into the script
Isolate that new posting using the rake isolate task
Open the new posting in Textmate (my editor of choice)
The hardest part of creating the script was getting the Rake tasks to run inside of a Ruby script, once I had that figured out the rest was easy.
Here is my script:
I’m relatively new to writing Ruby scripts so I’m sure this could be cleaned up a bit. Since Octopress is running on Ruby 1.9.2, this script must also be run against Ruby 1.9.2. Using RVM makes setting the current Ruby version easy so this is not an issue.
With the script installed and my path all I have to do to create a new posting and start editing is this:
The script takes care of the rest, which looks like this: