0

I had installed Sublime Text 3 a few months back, and using some online resource I had made it accessible through Unity Launcher(unfortunately, I don't remember which resource, or how I did it).

So, currently I can only open Sublime Text using launcher and to open a new file I have to use the menu(or Control+N).

I want to be able to open a file in sublime text using terminal.i.e something like:sublime_text newfile.txt.

Steps I took:

1.....

I searched and found that SublimeText folder(and the script) was in /opt directory.So I wrote a 2 line script to point to the script and run it, and then wrote an an alias called Sublime_Text to run that script and put it in the .bashrc file.

So now I can write Sublime_Text and it opens the sublime_text3 editor, but command like Sublime_Text newfile.txt does not give me a new file(only opens sublime_text and no newfile)

2.....

I tried to copy the sublime_text script originally in the /opt/sublime_text folder into /usr/bin/ directory (since vim, vi and other terminal commands are kept in that folder). Unfortunately,sublime_text newfile.txt shows several errors like:

Error loading colour scheme Packages/Color Scheme - Default/All Hallow's Eve.tmTheme: Unable to open Packages/Color Scheme - Default/All Hallow's Eve.tmTheme

and other 3 errors of the form: Error loading syntax file"XYZ"

1

You can launch Sublime Text 3 using subl or subl file in the terminal.

  • didn't know subl is actually sublime_text.question seems too stupid now. – spiderbat Feb 13 '15 at 4:26
1

The two simplest ways are going to be:

  1. add the directory containing the application to your PATH environment variable. For example, add a line like

    export PATH=$PATH:/opt/sublime_text
    

    to your ~/.bashrc file. You will need to log out and back in for the change to take effect, or re-source the file in your current shell e.g.

    source ~/.bashrc
    
  2. create a symbolic link from the executable file to somewhere that's already on your PATH e.g.

    sudo ln -s /opt/sublime_text /usr/local/bin/sublime_text
    

You will need to remove the copy of the script that you placed in /usr/bin so that the system doesn't find it first.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.