├── COPYING ├── readme.md └── open in sublime.applescript /COPYING: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | The best description (with pictures, even) of Open In Sublime is in the [wiki](https://github.com/pjv/open-in-sublime/wiki). 2 | 3 | The following probably barely makes sense :-O 4 | 5 | Version 2.1 fixes an issue where the script was popping up a dialog asking where Path Finder was located if it was not installed on the machine where the script was run. 6 | 7 | This version does a little two-step in order to work on systems that do not have Path Finder installed 8 | without popping up a dialog asking where it is. The idea here is to compile it with the needed terms 9 | from Path Finder's dictionary but save that compiled script such that it can then be exported as an 10 | application that no longer needs to have access to Path Finder in order to run. 11 | 12 | Complicated, I know. 13 | 14 | If you don't have Path Finder, you should just download the pre-compiled app from https://github.com/pjv/open-in-sublime/downloads 15 | 16 | With Path Finder installed, you can run the raw script from the repo here and it will create a NEW script in your home directory called "Open Folder in Sublime.scpt" 17 | 18 | Next you need to open that script in AppleScript Editor and Export as an application. 19 | 20 | Name the app "open folder in sublime" if you want it to always load the finder window directory. 21 | 22 | Name it anything else if you want it to open the finder selection. 23 | 24 | If you want it to look cool, do a cmd-i on Sublime Text 2, click on the icon in the upper left and copy, then cmd-i on the open in sublime app you just made, click its icon and paste. sweet. 25 | 26 | Version 2.0 of Open In Sublime has two new features: 27 | 28 | 1. It works with Path Finder as well as Finder 29 | 30 | 2. By popular demand and the work of ProLoser, this verison of Open in Sublime lets it open the finder selection in Sublime Text 2. You can have either the original behavior or the open selection behavior depending on how you name the application that you create in AppleScript. If you name the app "open folder in sublime" then you will get the original behavior which is to always load the open finder (path finder) window in Sublime's sidebar regardless of whether there is a selection in the window or not. If you name it anything else, then you will get the new behavior which is to open the selection if there is one and the directory if there is not. 31 | 32 | ##### Yosemite Tip 33 | If you are running Yosemite you can not just drag an app to your Finder Toolbar. In Yosemite you need to hold `command` and drag the app to the Finder Toolbar for it to "install". *Open-in-sublime* falls under this category. Reference from [Mac OS X Hints](http://hints.macworld.com/article.php?story=20131025093452688). 34 | 35 | -------------------------------------------------------------------------------- /open in sublime.applescript: -------------------------------------------------------------------------------- 1 | (** 2 | v. 2.1 3 | 4 | This version does a little two-step in order to work on systems that do not have Path Finder installed 5 | without popping up a dialog asking where it is. The idea here is to compile it with the needed terms 6 | from Path Finder's dictionary but save that compiled script such that it can then be exported as an 7 | application that no longer needs to have access to Path Finder in order to run. 8 | 9 | Complicated, I know. 10 | 11 | you will need to have Path Finder installed in order to compile or run this script 12 | if you don't have Path Finder, you should just download the pre-compiled app from https://github.com/pjv/open-in-sublime/downloads 13 | 14 | with Path Finder installed, you can run this script and it will create a new script in your home directory called "Open Folder in Sublime.scpt" 15 | next you need to open that script in AppleScript Editor and Export as an application. 16 | 17 | name the app "open folder in sublime" if you want it to always load the finder window directory 18 | name it anything else if you want it to open the finder selection 19 | 20 | Copyright © 2013 pjv 21 | This work is free. You can redistribute it and/or modify it under the 22 | terms of the Do What The Fuck You Want To Public License, Version 2, 23 | as published by Sam Hocevar http://www.wtfpl.net/. 24 | See the COPYING file for more details. 25 | 26 | **) 27 | 28 | using terms from application "Path Finder" 29 | 30 | script theScript 31 | 32 | on run 33 | 34 | -- find out if path finder is installed 35 | set pathfinder_installed to true 36 | try 37 | tell application "Finder" 38 | set pathFinder to name of application file id "com.cocoatech.pathfinder" 39 | end tell 40 | on error 41 | set pathfinder_installed to false 42 | end try 43 | 44 | if pathfinder_installed then tell application "System Events" 45 | -- if anyone knows a better way to find out if the script was 46 | -- launched from path finder, this would be a good place to put it 47 | set pathFinder_running to (get name of processes) contains "Path Finder" 48 | end tell 49 | 50 | if name of current application as string is "open folder in sublime" then 51 | set openFiles to false 52 | else 53 | set openFiles to true 54 | end if 55 | 56 | if pathfinder_installed and pathFinder_running then 57 | 58 | tell application pathFinder 59 | if openFiles then 60 | set finderSelection to {} 61 | set selectedItems to selection 62 | repeat with theItem in selectedItems 63 | copy (path of theItem as alias) to the end of finderSelection 64 | end repeat 65 | else 66 | set finderSelection to path of target of item 1 of finder windows 67 | end if 68 | end tell 69 | else 70 | tell application "Finder" 71 | if openFiles then 72 | if selection is {} then 73 | set finderSelection to folder of the front window as string 74 | else 75 | set finderSelection to selection as alias list 76 | end if 77 | else 78 | set finderSelection to folder of the front window as string 79 | end if 80 | end tell 81 | end if 82 | 83 | st2(finderSelection) 84 | end run 85 | 86 | -- script was drag-and-dropped onto 87 | on open (theList) 88 | st2(theList) 89 | end open 90 | 91 | -- open in Sublime 92 | on st2(listOfAliases) 93 | tell application "Sublime Text 2" 94 | open listOfAliases 95 | activate 96 | end tell 97 | end st2 98 | 99 | end script 100 | 101 | end using terms from 102 | 103 | store script theScript in (path to home folder as string) & "Open Folder in Sublime.scpt" 104 | --------------------------------------------------------------------------------