Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nilandev/f0aee591aef5e78ed878973836f26924 to your computer and use it in GitHub Desktop.
Save nilandev/f0aee591aef5e78ed878973836f26924 to your computer and use it in GitHub Desktop.
Launch Sublime Text 2 or 3 from the Mac OSX Terminal

Installation

Assuming you installed Sublime in the Applications folder

For Sublime Text 2:

$ open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

For Sublime Text 3:

$ open /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl

If that worked, you're good to go.

Create a symlink called sublime

You now need to create a symlink called sublime which links the subl CLI to a folder where your system usually looks to execute these binaries.

For Sublime Text 2:

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

For Sublime Text 3:

$ ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime	

Enter the following command into your Terminal:

$ nano ~/.bash_profile

Now add the following

export PATH=/usr/local/bin:$PATH

Finally, if you did have to add /usr/local/bin to your PATH, run the following command before continuing:

$ source ~/.bash_profile

This will reload your .bash_profile with the newly added directory in your PATH.

Test it works!

  • sublime . – opens the current directory in Sublime
  • sublime <file-name> – opens a file where filename is the file to be opened
  • sublime <folder-name> – opens a folder where foldername is the folder to be opened
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment