Sublime Forum

Command to start Sublime Text X from terminal?


Is there a way to start Sublime Text X from the terminal? I am on OSX and it would be nice to be able to set Sublime as the default editor for git commit messages etc. (Similar to TextMate’s "mate"command, and MacVim’s "mvim"command.)

(Of course, I can use /Applications/Sublime\ Text\ X/Contents/MacOS/Sublime\ Text\ X, but that is a bit cumbersome)




A binary launcher is definitely the ideal way to go so that you can set it as a default editor for tools.

In the meantime, I added the following alias to my ~/.bash_profile

alias slt='open -a "Sublime Text X"'

Then I can do:


Or, create a new project or add to the current project, I do:

slt folder/to/add/


I lieu of a binary, that is an excellent stopgap solution. Thanks.



No problem. It’s been working great for me. Would still like to see X as an OSX registered .app so that it can be assigned as a default editor for certain filetypes and such…



Would also love to be able to set my EDITOR environment variable to point to Sublime Text 2, so that it would integrate into command line tool usage: for example, run “svn commit” and have Sublime Text 2 pop open for me to type in a commit message.



I don’t have a Mac at hand to test this on, but you should be able to create a simple bash script that looks something like this:

#!/bin/sh open -a "Sublime Text X" "$@"

Mark it executable

chmod +x

and you can now run

./ filename filename2 filename3

And you can set it as your EDITOR :smile: if you put it in /bin you won’t need the path (./) either.



Is there an equivalent for Linux/Ubuntu?



On Linux, you can just pass the command line arguments directly to the excutable.

Personally, I have a symlink to sublime_text in my path called ‘subl’, so I can just type “subl readme.txt” to open a file.



I prefer:

slime dir/file




[quote=“jps”]On Linux, you can just pass the command line arguments directly to the excutable.

Personally, I have a symlink to sublime_text in my path called ‘subl’, so I can just type “subl readme.txt” to open a file.[/quote]

Could you offer some steps for this? I’m moving from Windows to Ubuntu, and can’t get this to work. I’ve tried following … e-symlink/ but am failing.



I would also like to be able to open files from the commandline with Sublime Text 2. I’m on Ubuntu and don’t know how to make a symlink. Could anyone help?



Hi guys,

Old topic, I know, but I have a symlink for those on Ubuntu looking to be able to open Sublime Text 2 directly from the terminal.

sudo ln -s /home/me/Applications/Sublime\ Text\ 2/sublime_text /usr/bin/subl

This will create a symlink to open files when you write

subl folder_name/file_name

If you want to change your call code (slime is cute), then just change the last part of the above code to be


Good luck!



I have set up a symlink as suggested in: and have also set ‘subl -w’ as my EDITOR, however I get the following error whenever I go to edit my crontab:

$ crontab -e
crontab: subl -w: No such file or directory
crontab: “subl -w” exited with status 1

Does anyone have the same problem or know what is going wrong here? Every other time EDITOR is invoked it works perfectly, I only have a problem with editing my crontab.




With the hint from, … -for-subl/

In addition to the ‘subl’ setup, I created a ‘subl_wait’ bash script for it,

#!/bin/sh subl -w $*

and set the following in my environment

export EDITOR='subl_wait'

This seems to work nicely for my ‘crontab -e’ and ‘git commit’.

If this works perfectly for everyone, perhaps it should be added to the official docs. =)



This can be done easily. I have my sublime text binary installed in my PATH, and I have the following setup in my .bash_profile to setup the EDITOR variable properly:

export EDITOR="$(which sublime) --new-window --wait"

Using $(which sublime) will get the full path to the executable. The options --new-window and --wait are useful when using sublime as your default EDITOR: --wait tells sublime text to wait until the window is closed to return to the terminal. --new-window is just handy because it will open the file for edit in – you guessed it-- a new window! Not neccessary, but i have lots of files open in sublime all the time and it just helps me keep track of what’s what.

To see all sublime command line options on *nix, use --help.

Hope this is useful.