Sublime Text 3 and opening folders

One of my petpeeves with an otherwise amazing editor is the fact that I can not open Folders as projects from the command line or from within Finder. However it’s easily fixed with a small service you can easily create or a symlink. So let’s do that today. Just follow along.

First off: and GUI

  1. Open Automator
  2. Choose Service as template.
  3. Select files or folders in
  4. Drag over “Run Shell Script” from your Library and set it up as follows:
    Shell : “/bin/bash”
    Pass input : “as arguments”

    bash /Applications/Sublime\ -n "[email protected]"

    Like so:
    Automator preview

  5. Save the service, and note that the name you give it when saving is what it will be called in the context menu. If Sublime opens a blank window, toggle the sidebar, and you will see the documents.

Console side of things

This is fairly simple actually; most of already have a symlink to use sublime from the terminal anyhow. If you have a symlink setup already - you’re done. If not; just do the following:

Open Terminal and run this command

ln -s /Applications/Sublime\ /bin/subl

You will now be able to open files and folders from the command line.

#opening a file
subl filename
#opening a folder
cd foldername
subl .
comments powered by Disqus