Open Sublime Text 3 from Terminal on Mac OS X

I find myself relying more and more on Sublime Text for my coding needs and as such I’m always on the lookout for a shortcut for my everyday Mac needs (as you guys know from my AppleScript shortcuts a while back).

Here’s a quick way to launch your files/folders from Terminal in Sublime.

Assuming you’ve installed Sublime Text 3 correctly on your Mac, this following command should open the app from Terminal :

$ open /Applications/Sublime\

If that works, you’re good to go.

Step 1 : Create a symlink called sublime 

$ ln -s "/Applications/Sublime" /usr/local/bin/sublime

Step 2 : Check that your system profile can find the symlink you just created.

$ open ~/.bash_profile

Step 3 : Add both these lines in if they’re not already in here & then save the file :

alias sublime="open -a /Applications/Sublime\"

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

Step 4 : Reload your bash_profile :

$ source ~/.bash_profile

Done ! You can now navigate to any of your code/script folders in Terminal and open them in Sublime with the following commands :

sublime .
sublime trial.js
sublime foldername

4 thoughts on “Open Sublime Text 3 from Terminal on Mac OS X

  1. Hello!!!
    I’m getting an error after I’m typing this:
    ln -s “/Applications/Sublime” /usr/local/bin/sublime
    The error message is:
    ln: /usr/local/bin/sublime: Permission denied
    Any thoughts?
    Thank you

    • I found the problem!!!!!
      I just added sudo at the beginning and it worked!
      And one more thing that didn’t worked for me is in this code:
      $ open /Applications/Sublime\
      I needed to enter an “l” (L in lowercase) at the end “subl”
      Thanks anyway!!!!

Leave a message :)

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s