Created
March 13, 2012 14:49
-
-
Save clauswitt/2029236 to your computer and use it in GitHub Desktop.
Applescript to create a (jekyll) blogpost from Launchbar and open it in Sublime Text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on replaceString(theText, oldString, newString) | |
local ASTID, theText, oldString, newString, lst | |
set ASTID to AppleScript's text item delimiters | |
try | |
considering case | |
set AppleScript's text item delimiters to oldString | |
set lst to every text item of theText | |
set AppleScript's text item delimiters to newString | |
set theText to lst as string | |
end considering | |
set AppleScript's text item delimiters to ASTID | |
return theText | |
on error eMsg number eNum | |
set AppleScript's text item delimiters to ASTID | |
error "Can't replaceString: " & eMsg number eNum | |
end try | |
end replaceString | |
on handle_string(theString) | |
set cdCommand to "cd ~/Documents/Projects/clauswitt.com; " | |
set rakeCommand to "rake post title=" | |
set rakeName to "\"" & theString & "\"" | |
set completeCommand to cdCommand & rakeCommand & rakeName | |
set returnValue to do shell script completeCommand | |
set x to paragraph 4 of returnValue | |
set x to replaceString(x, "./", "/Users/claus/Documents/Projects/clauswitt.com/") | |
tell application "Sublime Text 2" | |
open x | |
end tell | |
end handle_string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment