Sublime Text 3: Using the OS X Command Line


The Problem

Sublime Text 3 includes a command line tool, subl. Unfortunately, this tool doesn’t work right out of the box after you’ve installed the editor on OS X Yosemite.

My Solution

After installing Sublime Text 3, create a symbolic link using the following command:

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

Here,

  • /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl is the location where the application is stored in your Applications directory.
  • /usr/local/bin is the chosen path where you want the symbolic link to reside.

To set Sublime Text as the default editor for various commands that prompt for input, configure your EDITOR environment variable as follows:

export EDITOR='subl -w'

The -w flag ensures that the subl command will not exit until the file is closed.

Additionally, you can set Sublime Text as your default Git editor with this command:

git config --global core.editor "subl -n -w"