For example, I have Sublime Text that I can open from Spotlight. However, sometimes I'm navigating with the terminal and I want to do sublime source.php
, but since I don't have the sublime app accesible from the Terminal, I need to do all the way from opening the app to navigating in finder to the location I already have opened in the terminal.
Is there a way to include applications installed in the Apps folder in the terminal PATH?
1 Answer
You can easily add the Applications directory to your PATH but it will not do anything useful as it is a collection of OSX apps which are bundles and can't be run from the command line.
There are several alternatives
- Use the open command which will open any OSX app e.g.
open -a Sublime\ Text.app source.php
This works for all apps - Find the unix executable in the app bundle usually in Contents/MacOS and with a similar name to the app.
- Some apps e.g. Sublime provide a specific command line tool and use that. This is what is suggested in Sublime's documentation However I would just create an alias to the full path
"/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl"
and use the full path in the EDITOR environment variable
-
To your item 2, the executable file for Sublime Text 2.app bundle as defined in its info.plist file is Sublime Text 2, not the python script. There is a binary executable named "Sublime Text 2" in the MacOS folder. Commented Mar 21, 2016 at 15:59
-
1I see you edited item 2 however to your last comment... In "Sublime Text 3" the App bundle is just called "Sublime Text", no number like in the second version, and it's defined executable, per its info.plist file, is too a binary executable of the same name, not the python script that is also in the MacOS folder. Anyway the answer still gets a +1 from me. :) Commented Mar 21, 2016 at 16:37
$PATH
. Just make a symlink to thesubl
binary as discussed in: sublimetext.com/docs/2/osx_command_line.html