Home Download Buy Blog Forum Support

Command to start Sublime Text X from terminal?

Re: Command to start Sublime Text X from terminal?

Postby Cane on Wed Jul 06, 2011 11:16 am

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?
Cane
 
Posts: 2
Joined: Mon Jan 17, 2011 6:39 pm

Re: Command to start Sublime Text X from terminal?

Postby Coleslaw on Wed Nov 16, 2011 1:20 am

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.

Code: Select all
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

Code: Select all
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

Code: Select all
/usr/bin/your_name_here


Good luck!
Coleslaw
 
Posts: 1
Joined: Wed Nov 16, 2011 1:15 am

Re: Command to start Sublime Text X from terminal?

Postby slprsrvc on Mon Dec 12, 2011 3:12 pm

Hello,
I have set up a symlink as suggested in: http://www.sublimetext.com/docs/2/osx_command_line.html 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.

Thanks,
Matt
slprsrvc
 
Posts: 6
Joined: Tue Jul 05, 2011 2:04 pm

Re: Command to start Sublime Text X from terminal?

Postby seantan on Tue Jan 31, 2012 2:19 am

With the hint from,

http://sublimetext.userecho.com/topic/9 ... -for-subl/

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

Code: Select all
#!/bin/sh
subl -w $*


and set the following in my environment

Code: Select all
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. =)
seantan
 
Posts: 3
Joined: Wed Nov 16, 2011 2:26 am

Re: Command to start Sublime Text X from terminal?

Postby TheShaz on Fri Sep 07, 2012 7:23 pm

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


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:

Code: Select all
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.
TheShaz
 
Posts: 1
Joined: Fri Sep 07, 2012 7:01 pm

Previous

Return to Technical Support

Who is online

Users browsing this forum: No registered users and 34 guests