Today I decided I wanted to be able to run Sublime Text from my Terminal. Did a bit of Googling and pieced together the steps here.

Setting up “bin” in your home directory
1. Make a folder called “Bin” in your home directory if it doesn’t already exist. If you’re not sure how or what I mean, open a Terminal and type:


You’re now in your home directory! Now we’ll create a directory called “bin”:

mkdir bin

Link up your Sublime application file to a shortcut
2. Once that’s created run this command to create a symlink to your Sublime Text installation (note this is for Sublime Text 2):

ln -s "/Applications/Sublime Text" ~/bin/subl

Check if it works!
3. Restart your Terminal and it may already work. Type in:

subl --help

Do you see help text that starts with “Sublime Text 2 Build…”? If so, hooray for efficiently and skipping everything else. Go straight to step 9.

For me though, I wasn’t so lucky and had to do a bit more. If you’re as unfortunate as me, continue along!

Update your .bash-profile file to look in our ~/bin directory
4. Go to your home directory again:


5. Open up your .bash-profile file (in vim or whichever other text editor you can use until we get Sublime in there!):

vim .bash_profile

6 (I know Vim). If you know Vim or whichever other text editor you used above, just add the following to the end of the file:

export PATH=$PATH:~/bin

Wha? What is this vim you speak of?
6 (I don’t know Vim). Not sure how to use Vim? Follow along!

Firstly press the letter “i” on your keyboard to get into insert mode.

Then type in:

export PATH=$PATH:~/bin

Press “esc” to leave insert mode.
Type in this to save your file and close it:


Testing if our update worked!
7. Close your terminal and open it again.
8. Type in:

subl --help

Hopefully that comes up with help text that starts with “Sublime Text 2 Build…”. If so, tis happy times!

Opening up files
9. Now to open any file, you can use the subl command like so:

subl textiwanttoedit.txt

Have fun with your newly Terminally-accessible Sublime Text 2!

Leave me a comment!

Your email address will not be published. Required fields are marked *