Ubuntu – Launch Sublime Text 2 from terminal

binarycommand linesublime-textsudo

I am new to Ubuntu and is trying to configure my environment so i can launch Sublime Text 2 directly from the terminal. I followed the solution on this post but no luck so far.

These are steps I did (steps from this post):

-> cd 
-> mkdir bin
-> sudo ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/bin/subl

In my .bash_profile I added: export PATH=$PATH:~/bin

This is the error I got:
~$ subl –help
No command 'subl' found, did you mean:
Command 'subs' from package 'libsubtitles-perl' (universe)
Command 'publ' from package 'atfs' (universe)

First of all, I don't understand why we need to create a bin folder. This folder is now in Home/bin and I don't think I am using it. (I know there are two bin folders. One in File System/usr/bin and the other one File System/usr/local/bin. I am not sure the difference here.)

Second, I noticed that after I ran the command above (sudo ln -s…) I created a link in my usr/bin folder. However, when I checked this link file, it said the link is broken so i suspect that there is something wrong with the sudo command I executed.

ERROR: This link cannot be used, because its target "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" doesn't exist.

This commnad:

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

Does /Applications/Sublime Text 2.app indicates the location of my sublime text 2? If yes, then my sublime text is actually in Home/Programs/Sublime Text 2. So should I change the command to sudo ln -s "/Programs/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/bin/subl ?

I already tried this, but since there is already a link file in my usr/bin, I got an error when I tried to run the command above.

ERROR: ln: failed to create symbolic link `/bin/subl': File exists When I attempted to remove it, it said permission denied.

Sorry, I am asking a lot because I am new to Ubuntu. Any help will be appreciated. Thanks a lot.

Best Answer

Using this approach (the ppa one) to install Sublime Text would allow you to open it from the terminal using subl or sublime-text without the need of additional configuration.

Related Question