Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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"
share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

I finally was able to solve that problem.

I had to update the batch file like this:

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

Basically, using %~dp0 for the execdir and %~1 for the file to launch were sufficient enough to do the trick.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.