Lessons: 34Length: 2.5 hours

Next lesson playing in 5 seconds

  • Overview
  • Transcript

2.2 Services and Opening Sublime From the Terminal

In this lesson, mostly for the Mac users among you, we'll add a service, so that we can right-click on a folder, and open the files within Sublime.

Note: recent versions of Mac OS may require that the Automator service be configured to pass input as arguments rather than to stdin.

2.2 Services and Opening Sublime From the Terminal

One thing that would be nice on the Mac, and I'm sorry guys, this is more Mac specific in this video. So if you're a Windows user, feel free to move onto the next one. I would like to right-click on Project and choose something like, Open in Sublime Text 2. That would be helpful, right? That's not offered out of the box, but we can provide that functionality fairly easy. So I will open Automator, which all Mac users have, and we're going to add a new service. Now, the action that I want to run is a shell script, so I'll bring that in. So now, when we execute this service, it's going to run a shell script, and I'll paste this in. This is path to the Sublime text executable, and then I'm passing dash into create a new project with the given files. So now, our service should receive file or folders, whatever we specify,. And that's really all there is to it. So I'll hit save, and we're going to save it as Open-in-Sublime. And now if I close this out, I right click on the folder. Go down to services. We have a new option, Open-in-Sublime, and there we go. So now that we have the ability to right click on a folder and open it in Sublime, let's also offer the same functionality from the terminal. Ideally I should be able to within a folder just run Sublime, and that will open up Sublime with the current directories files in the side bar. But if I run it right now, nope that's not going to work. So let's add that functionality. It's a fairly easy process. All we have to do is create the symbolic link. So what I have here is, we're creating a new linking. I'm passing dash-s to create symbolic link. The first parameter is the full path to that Sublime executable, and now I'm creating the reference, or you can think of it as like an alias or pointer to the original file, and I'm placing that within my bin. Now, if you get this error right here like I did, permission denied, you may need to do sudo. So I'll do sudo, and a quick tip here, if I do exclamation point, exclamation point. That's going to bring in the last command that I ran. So if I run that, now notice that it just pastes that in. And if I run it, now we've created the symbolic link. So at this point you may need to restart the terminal, but once you do, now I will run Sublime period. And now everything has been opened and we're all set to go.

Back to the top