Launch Sublime Text 2 from command line

Posted by Erick on Super User See other posts from Super User or by Erick
Published on 2012-12-11T14:41:11Z Indexed on 2012/12/17 17:06 UTC
Read the original article Hit count: 327

I am trying to launch Sublime Text 2 via command line.

I know it has already been done before here but I am having different constraints. I use the portable version of ST and store it into my Dropbox account. I guess you can see me coming here.

I need to launch subtext on a relative path. So far it "kinda works" if I type in the command line subl file.txt it works I see the file content but if I type subl "file 2.txt" I do not have nothing it opens ST with something like c:\mydir\"file 2.txt".

I guess the problem lies on the "%WORKINGDIR%\%1" of the script bellow.

@ECHO OFF  
SET WORKINGDIR=%CD%  
cd /d %0\..  
SET EXECDIR=%CD%  
cd %WORKINGDIR%  
START "Sublime text editor" "%EXECDIR%\sublimetext\sublime_text.exe" "%WORKINGDIR%\%1"

© Super User or respective owner

Related posts about Windows

Related posts about command-line