Home Download Buy Blog Forum Support

Here's my subl.cmd script for Windows

Here's my subl.cmd script for Windows

Postby milnak on Fri Jan 11, 2013 2:16 am

I don't like adding a bunch of paths to my PATH statement, and i'm mostly in the command line, so I created this script. Save it (in your path) as subl.cmd and run it. it supports wildcards.

Code: Select all
@ECHO OFF
SETLOCAL

CALL :GetStPath
IF "%StPath%"=="" ( ECHO Can't find Sublime Text & GOTO :EOF )

PATH %StPath%;%PATH%

set LIST=
:NEXTARG
IF "%~1"=="" GOTO :START
FOR %%i IN (%1) DO CALL :ADDARG "%%~fi"
SHIFT
GOTO :NEXTARG

:ADDARG
SET LIST=%LIST% %1
GOTO :EOF

:START
START "Sublime Text" sublime_text.exe --add %LIST%
GOTO :EOF

:GetStPath
SETLOCAL
FOR /F "skip=2 delims=" %%f IN ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Sublime Text 2_is1" /v InstallLocation') DO SET P=%%f
ENDLOCAL & SET StPath=%p:~33%
GOTO :EOF
milnak
 
Posts: 5
Joined: Fri Jan 11, 2013 2:14 am

Return to General Discussion

Who is online

Users browsing this forum: Yahoo [Bot] and 18 guests