outcoldman
outcoldman Denis Gladkikh

Sublime Text: subl command under windows command line

Windows, Command Line, subl, Sublime Text, and 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

Have feedback or questions? Looking for consultation?

My expertise: MongoDB, ElasticSearch, Splunk, and other databases. Docker, Kubernetes. Logging, Metrics. Performance, memory leaks.

Send me an email to public@denis.gladkikh.email.

The content on this site represents my own personal opinions and thoughts at the time of posting.

Content licensed under the Creative Commons CC BY 4.0.