Home Download Buy Blog Forum Support

Command to start Sublime Text X from terminal?

Command to start Sublime Text X from terminal?

Postby HelgeG on Fri Jan 14, 2011 10:34 am

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)

Cheers,
Helge
HelgeG
 
Posts: 4
Joined: Mon Jan 10, 2011 9:36 am

Re: Command to start Sublime Text X from terminal?

Postby willi297 on Fri Jan 14, 2011 2:57 pm

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
Code: Select all
alias slt='open -a "Sublime Text X"'


Then I can do:
Code: Select all
slt my_stuff.py


Or, create a new project or add to the current project, I do:
Code: Select all
slt folder/to/add/
Greg Williams
Atomic Embedded, USA
http://atomicembedded.com
willi297
 
Posts: 121
Joined: Wed Nov 18, 2009 8:29 pm
Location: Grand Rapids, MI, USA

Re: Command to start Sublime Text X from terminal?

Postby HelgeG on Fri Jan 14, 2011 4:20 pm

I lieu of a binary, that is an excellent stopgap solution. Thanks.
HelgeG
 
Posts: 4
Joined: Mon Jan 10, 2011 9:36 am

Re: Command to start Sublime Text X from terminal?

Postby willi297 on Tue Jan 18, 2011 2:47 pm

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...
Greg Williams
Atomic Embedded, USA
http://atomicembedded.com
willi297
 
Posts: 121
Joined: Wed Nov 18, 2009 8:29 pm
Location: Grand Rapids, MI, USA

Re: Command to start Sublime Text X from terminal?

Postby singingwolfboy on Sun Jan 30, 2011 3:47 pm

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.
singingwolfboy
 
Posts: 3
Joined: Sun Jan 30, 2011 3:33 pm

Re: Command to start Sublime Text X from terminal?

Postby firejdl on Thu Feb 03, 2011 3:46 am

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:

Code: Select all
#!/bin/sh
open -a "Sublime Text X" "$@"


Mark it executable
Code: Select all
chmod +x sublime.sh

and you can now run
Code: Select all
./sublime.sh filename filename2 filename3

And you can set it as your EDITOR :) if you put it in /bin you won't need the path (./) either.
firejdl
 
Posts: 9
Joined: Thu Feb 03, 2011 3:35 am

Re: Command to start Sublime Text X from terminal?

Postby DarkRoot on Mon Feb 28, 2011 6:23 pm

Is there an equivalent for Linux/Ubuntu?
DarkRoot
 
Posts: 1
Joined: Mon Feb 28, 2011 6:22 pm

Re: Command to start Sublime Text X from terminal?

Postby jps on Tue Mar 01, 2011 12:34 am

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.
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: Command to start Sublime Text X from terminal?

Postby adc on Wed Apr 20, 2011 3:47 pm

I prefer:
Code: Select all
slime dir/file


;)
adc
 
Posts: 3
Joined: Thu Mar 17, 2011 5:19 pm

Re: Command to start Sublime Text X from terminal?

Postby catguy on Fri Apr 29, 2011 7:23 am

jps wrote: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.


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 http://linux.byexamples.com/archives/19 ... e-symlink/ but am failing.
catguy
 
Posts: 1
Joined: Fri Apr 29, 2011 7:21 am

Next

Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 22 guests