Denis Gladkikh


My personal blog about software development

  • 06 Jan 2014
  • Windows, Command Line, subl, Sublime Text, CLI

Strange that Sublime Text documentation does not include manual about how to make subl command available on Windows in command line environment. One of the reasons can be that Sublime Text does not have so many users on Windows as on Mac OS, or maybe because not so many Windows developers use command line on Windows.

Anyway, below is my way of doing it. I just place subl.cmd file under %WINDIR% (which is C:\Windows by default).

@echo off
SET Sublime_Executable=
IF DEFINED ProgramFiles(x86) (
  set Sublime_Executable="%ProgramW6432%\Sublime Text 3\sublime_text.exe"
) ELSE (
  set Sublime_Executable="%ProgramFiles%\Sublime Text 3\sublime_text.exe"
start "" %Sublime_Executable% %*

After that you can use some of the default commands, like

@echo Open new instance of Sublime Text
subl -n
@echo Open current folder in new instance of Sublime Text
subl . -n
@echo Open file filename.txt in current instance of Sublime Text
subl filename.txt