Sublime Forum

Subl for Windows

#1

Can we please get a proper port of the “subl” command line command for Windows?

Users can almost hack together this, by:

  1. Adding the Sublime Text installation directory to PATH.
  2. Launching a Git Bash terminal.
  3. Calling sublime_text &.
  4. Closing the duplicate project window that comes up (Sublime thinks you always want to open the last project).

None of these four things should be things users have to deal with in a proper “subl” command.

  • subl.exe’s directory should be appended to PATH during Sublime Text installation in Windows.
  • subl should fork a thread for itself, returning control to the terminal it was called from.
  • subl should not open the last project but only its argument .
0 Likes

#2

True, but some people are forced to use windows but would still like to be able to do normal things like setting up a batch process that involves the usage of SublimeText. I have no choice but to use windows at work and often create dos batch scripts to help with repetitive tasks. Having good command line access to applications has saved me a lot of time and seriously reduced the risk of human error creeping into some daily tasks that I need to perform.

Command line access will not always be done via the command prompt.

0 Likes

#3

Right, I’m on windows and use conemu so the argument about cmd being horrible is irrelevant .

For a start we need a subl.bat file in the system path. The following will run sublimetext without holding up the current window and without creating a new command window.

@echo off @START C:\"Program Files"\"Sublime Text 2"\sublime_text.exe "%1"

Now my question is, is there a parameter that can be passed to sublimetext telling it not to open the last open project in a separate window? If so, it would be easy to add that parameter into the subl.bat file.

One work around is to stop sublimetext from storing session data by adding the following to the user preferences

"hot_exit": false, "remember_open_files": false

The drawback is the next time you open it there will be no projects or files but if your workflow is to always run one project at a time and run it from command line then this works fine.

Not sure if any of those other parameters for the OSx subl are useful sublimetext.com/docs/2/osx_command_line.html, but it would be great if anyone knows how to add any of them to the subl.bat file would share it here.

0 Likes

#4

This is a problem on Linux as well (I have no idea about OSx). It’s been reported and discussed several times on the forum and has been opened as an issue on the unofficial bugtracker: github.com/SublimeText/Issues/issues/28

Maybe if windows users start complaining too, some of the command line issues will get looked at.

I use the Windows command prompt quite often; I imagine many other programmers do as well (actually, I’d have thought most programmers on Windows use it). And don’t forget that command lines are also used in other places other than the command prompt, such as when you try to configure a version control system to use ST as the editor for commit messages.

0 Likes

#5

Just created an account mainly to thank “iansane” for his reply which was exactly what I was looking for.

I put st.bat in my path
Contents of st.bat

@start sublime_text.exe %1 %2 %3 %4 %5 %6 %7 %8 %9

added Sublime’s path to my path environment variable by appending the following to the path (’;’ separated)

C:\Program Files\Sublime Text 2\

Finally, the most important step of addnig to preferences/user settings

"hot_exit": false,
"remember_open_files": false

My whole settings file for completeness, commas required every line but the last

{
	"color_scheme": "Packages/Color Scheme - Default/Blackboard.tmTheme",
	"ignored_packages":
	
		"Vintage"
	],
	"tab_size": 3,
	"theme": "Soda Dark.sublime-theme",
	"translate_tabs_to_spaces": true,
   "remember_open_files": false,
   "hot_exit": false
}

And now, I can go into a directory on the command line and type

st .htaccess index.php

and it loads up those two files (or up to 9) from the command line

Day 2 of playing with Sublime Text 2. I think it’ll be a nice addition to my normal workflow of Netbeans for editing files quickly.

0 Likes