Home Download Buy Blog Forum Support

subl for Windows

subl for Windows

Postby mcandre on Tue Feb 19, 2013 3:09 pm

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 <file or directory> &.
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 <file or directory>.
mcandre
 
Posts: 5
Joined: Sat Nov 10, 2012 5:40 am

Re: subl for Windows

Postby jkw on Wed Feb 20, 2013 11:15 am

Why would you need a command-line for Windows when the Command Prompt is awful?
jkw
 
Posts: 17
Joined: Sun Nov 04, 2012 3:02 pm

Re: subl for Windows

Postby jbjornson on Wed Feb 20, 2013 1:54 pm

jkw wrote:Why would you need a command-line for Windows when the Command Prompt is awful?


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.
jbjornson
 
Posts: 350
Joined: Tue Oct 27, 2009 4:25 pm
Location: Zurich, Switzerland

Re: subl for Windows

Postby iansane on Tue Jun 25, 2013 1:01 am

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.
Code: Select all
@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
Code: Select all
"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 http://www.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.
iansane
 
Posts: 8
Joined: Sun Nov 06, 2011 11:16 pm

Re: subl for Windows

Postby mwb1100 on Tue Jun 25, 2013 6:16 pm

iansane wrote: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.

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: https://github.com/SublimeText/Issues/issues/28

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

jkw wrote:Why would you need a command-line for Windows when the Command Prompt is awful?

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.
mwb1100
 
Posts: 43
Joined: Mon Jun 25, 2012 5:40 pm

Re: subl for Windows

Postby MichaelG on Fri Jan 31, 2014 1:50 am

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
Code: Select all
@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)
Code: Select all
C:\Program Files\Sublime Text 2\


Finally, the most important step of addnig to preferences/user settings
Code: Select all
"hot_exit": false,
"remember_open_files": false


My whole settings file for completeness, commas required every line but the last
Code: Select all
{
   "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
Code: Select all
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.
MichaelG
 
Posts: 1
Joined: Fri Jan 31, 2014 1:42 am


Return to Ideas and Feature Requests

Who is online

Users browsing this forum: No registered users and 8 guests