I like the idea, but it looks as though the path to subl in main.scpt is a hardcoded path specific to your machine. I was able to fix it by simply changing the path to the location within Sublime Text 2.app:

jon4than wrote:I like the idea, but it looks as though the path to subl in main.scpt is a hardcoded path specific to your machine. I was able to fix it by simply changing the path to the location within Sublime Text 2.app:

thanks for the fix. github repo updated with fixed version of the app.

fwiw, i tried to come up with a way to let applescript find the path to Sublime Text 2 (in case user keeps it somewhere other than /Applications) and use that path to find the way to subl, but for some reason even when applescript had the path right, the do shell script command would bomb telling me that there was no such file

Thanks for the script! I hadn't even thought about this yet, it's sure to make my work a bit more fluent.

I modified your script a bit to work on the current selection and fallback on the current folder if no file is selected, this way I can use it to open files or folders I have selected as well. I would have forked your script on Github and requested a pull, but it seems you haven't actually committed the code on github, so here are the modifications:

tell application "Finder" copy selection to theSelected set outputPathList to {} repeat with anItem in theSelected copy (POSIX path of (anItem as alias)) to end of outputPathList end repeat set AppleScript's text item delimiters to return set currentPath to outputPathList as string set AppleScript's text item delimiters to "" if currentPath is equal to "" then set currentPath to (POSIX path of (target of front window as string)) end if

I don't know much about Applescript so I pretty much cut and paste this together from online resources, I'm sure that someone who has played around with Applescript more than I have can come up with a cleaner version, but this does the job.

@handycam, @minimalweb: yes, you can do both of those things, the only thing that this little app adds in terms of convenience is the ability to do a one-click open of the current directory that is open in a finder window. if you want to drag a folder onto the ST2 icon to open it up, your finder window has to be showing you the parent of the directory you are interested in. i find that i often am looking at the contents of the directory that i want to work in, so it is convenient to have one-click ST2 access to that directory. it's not a big deal, i just like it and thought others might too.

@Naatan: i didn't commit the code because the app doesn't run as just a script and it seemed like a lot of extra work for people to open it up in applescript, save it as an app, copy paste the icon, etc. for such a simple little one-trick pony. but i will pull out the main script from the app and commit that. i thought about doing what you did in terms of opening the current selection, but then i realized that it was already easy to do that for files with a right-click "open with" from the finder and all i really wanted was for ST2 to open the current finder window folder. but i'm glad you made it work for you.

update: acchh, never mind. the main.scpt is binary too. there's really no code worth committing to the repo, i don't think.

i'm going to keep trying to find a solution that lets me dynamically find the way to the subl inside ST2 so that people who keep it somewhere other than /Applications could also use this without having to re-compile it. if i figure out how to make that work, i'll post back here and update the repo. but for anyone who wants to modify the behavior and/or location of subl, you can just open the app up in the applescript editor and make it do as you like.

pjv wrote:i'm going to keep trying to find a solution that lets me dynamically find the way to the subl inside ST2 so that people who keep it somewhere other than /Applications could also use this without having to re-compile it. if i figure out how to make that work, i'll post back here and update the repo. but for anyone who wants to modify the behavior and/or location of subl, you can just open the app up in the applescript editor and make it do as you like.

ok, so i finally figured out how to find subl dynamically. i've updated the version of the app at github. here is the code that is in there, fwiw:

I see you've committed it on github as a txt, just a suggestion, if you rename it to code.applescript (or "open in sublime.applescript" for that matter), people can just double click it and save it as an app for easy compilation.