Skip to content

Instantly share code, notes, and snippets.

@collindonnell
Last active December 10, 2015 18:09
Show Gist options
  • Save collindonnell/4472948 to your computer and use it in GitHub Desktop.
Save collindonnell/4472948 to your computer and use it in GitHub Desktop.
Create a new Octopress post from LaunchBar.
(*
Create a new post in Octopress from Launchbar
Author: Collin Donnell
Website: http://collindonnell.com
Date: 01/06/2013
*)
on handle_string(postTitle)
try
-- Change these to match the path to your Octopress folder.
set octopressLocation to ((path to home folder as text) & "Code:blog:") as alias
set sourceFolder to ((octopressLocation as text) & "source:_posts:") as alias
tell application "Terminal"
activate
-- Run our commands in a new Terminal window
do script "cd " & quoted form of (POSIX path of octopressLocation) & "&& rake new_post[\"" & postTitle & "\"]"
-- Wait for the file to finish being created
repeat while window 1 is busy
delay 0.5
end repeat
-- Get the path to the newly created file and open it
set shellScript to "cd " & quoted form of (POSIX path of sourceFolder) & "&& ls -t"
set filePath to paragraph 1 of (do shell script shellScript)
do shell script "open " & quoted form of ((POSIX path of sourceFolder) & filePath)
end tell
on error errorMessage
display dialog "Error Creating Post: " & errorMessage
end try
end handle_string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment