Sublime Text 2 Service
Asked Answered
E

3

5

I'm attempting to make an open in Sublime Text 2 service via Automator.

I am doing this by:

  • Running Automator
  • Adding a new service
  • Adding "Run Shell Script"
  • Setting Shell to /bin/zsh
  • Entering a command line of: /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl -n $@
  • Setting "Service receives selected" to "files or folders"
  • Click save

Screenshot:

enter image description here

However, whenever I try to open a folder via right-click > services > "Open in Sublime", a new ST2 window is opened but with a randomly named text file (ie subl stdin N188RN.txt) and it's output is the path of the folder opened (ie: /Users/me/Desktop/project).

Screenshot:

enter image description here

Is there a way I can modify the automator command line to fix this?

Equate answered 14/1, 2013 at 19:16 Comment(0)
S
13

Try setting Pass input: value to as arguments:

enter image description here

Scilla answered 14/1, 2013 at 22:21 Comment(1)
Beautifully simple. Thank you.Equate
C
6

Enable OSX Mountain Lion Context Menu Launch:

  1. Open Automator. Add new service.
  2. Search for "Run Shell Script". Drag over to the panel on the right (or double click it).
  3. Enter:

    /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl -a $@

  4. Set "Pass Input:" to "As Arguments"
  5. Set "Shell" to "bin/zsh"
  6. Set "Services Receives Selected:" to "files or folders"
  7. Save as "Open-in-Sublime".

To use: right-click on a file or folder, and click 'Open-in-Sublime' in the 'Services' menu at the bottom of the context menu.

Enable OSX Mountain Lion Terminal Launch:

  1. At the command line enter:

    sudo mkdir /usr/local/bin

  2. Then enter:

    sudo ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime

  3. ln creates a link. -s makes it a symbolic link.
  4. You may need to prefix the command with sudo if it doesn't work.
  5. Restart the terminal.

To use:

user$ sublime . [This will open the current folder structure in Sublime]

user$ sublime <filename> [This will open the desired file in Sublime]

Cumuliform answered 4/4, 2013 at 7:9 Comment(1)
Lots of other tutorials recommend pushing the symbolic link to /bin/subl but your suggestion of /usr/local/bin/subl was just what I needed to get this to work. Thanks!St
U
0

Try setting Pass input: value to as arguments.

And "/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl" Path should in double quotes.

Undertone answered 13/9, 2013 at 18:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.