terminal command for running sublime text 3 from on ubuntu

3.9k Views Asked by At

I've installed a new dev machine using Ubuntu 14.02. I have also installed all the relevant software. php/apache2/sublime/composer etc.

I'd like to be able to open files with a sublime or subl command in the terminal, but can't seem to find the command to point things correctly.

My sublime executable resides here... /opt/sublime_text/sublime_text

in /usr/bin/subl I have the command

#!/bin/sh
exec /opt/sublime_text/sublime_text "$@"

I just can't find the command in the terminal to make it happen. The sublime documentation points to mac instructions, but I'm too newby to translate.

Any suggestions?

2

There are 2 best solutions below

0
On BEST ANSWER

As per Mathias comment in my question I found the answer here...

How can I open Sublime Text 2 files from the command line in linux to a tab, not a new window

0
On

$@ in a shell script basically copies all arguments given to the shell script (after the name of the script) and places them at that point during execution of the script.

For example, if you were to run subl test.txt, it would be as though you are running exec /opt/sublime_text/sublime_text "test.txt".

Now, /opt/sublime_text/sublime_text --help or subl --help gives us help text which shows the usage as well.

Sublime Text build 3065

Usage: sublime_text [arguments] [files]         edit the given files
   or: sublime_text [arguments] [directories]   open the given directories

Arguments:
  --project <project>: Load the given project
  --command <command>: Run the given command
  -n or --new-window:  Open a new window
  -a or --add:         Add folders to the current window
  -w or --wait:        Wait for the files to be closed before returning
  -b or --background:  Don't activate the application
  -h or --help:        Show help (this message) and exit
  -v or --version:     Show version and exit

Filenames may be given a :line or :line:column suffix to open at a specific
location.

If you pass more than one parameter, then all of them are also treated the same. So, if you ran subl file1.txt file2.cpp file3.html then it'd open all 3 of those files.