Search code examples
pathsublimetext3

How do I change the $PATH so I can launch Sublime Text from the command line?


Currently when I type echo $PATH the below appears:

/Library/Frameworks/Python.framework/Versions/3.8/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/mongodb/bin

I deleted mongodb, but this path shows up. I don't know how to get rid of that.
How do I get to the place where I can type:

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

Per Colt Steele's class.


Solution

  • You can type in your ln command directly into Terminal where you typed the echo command. The components in your $PATH (not $SPATH) are separated by colons (:), and if you look at the results you'll see that /usr/local/bin is already there, so you don't need to alter the path. Don't worry about the mongodb setting, it's not hurting anything.

    Please note that in order to run that ln command, you'll need to use sudo:

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

    and type in your administrator password, as /usr/local/bin is a protected directory.

    Once you've done all this, you'll be able to open a file in Sublime from Terminal by typing

    sublime filename