Sublime Forum

Querying Sublime from AppleScript for Alfred

#1

I am trying to make Sublime and Alfred talk to one another since both are pretty amazing productivity tools. That requires Alfred to be able to tell what the active file in Sublime is. That brings up the question: How can AppleScript query the name/path of the file that the Sublime editor is currently working on (i.e. active file in active tab)?

I tried the following AppleScript but it didn’t work

 tell application "Sublime Text 2" to set filePath to get path of document 1

I also tried to query the AppleScript commands of Sublime using AppleScript Editor, but that didn’t go anywhere, because Sublime doesn’t include an AppleScript dictionary. For a few rudimentary commands, there ought to be a way.

Note that there is an AppleScript way of getting Sublime to push buttons in the menu such as

tell application "System Events" tell process "Sublime Text 2" to click menu item "New File" in menu "File" of menu bar 1 end tell
But I want the opposite: reading from Sublime status information using AppleScript.

0 Likes