I have found the following Sublime command to be really useful since it opens an explorer window at the location of the current file:
{ "keys": ["ctrl+alt+o"], "command": "open_dir", "args": {"dir": "$file_path", "file": "$file_name"} },
What I would love is a similar command that will open a cmd window instead. Ideally at the root project folder, but current file directory would also be fine.
Have read the following question, but can't quite figure out how to use this in a sublime plugin/command: BAT file to open CMD in current directory
preference
>Browser Packages
in Sublime Text 2.Cmd
in the directory opened in step 1.cmd.py
with the following code in theCmd
folder created in step 2.Context.sublime-menu
with the following code in theCmd
folder created in step 2.Now you can open the Cmd prompt at the current directory in the right-click context menu.
A non-python method.
Menu
>Preferences
>Browser Packages
.user
directory.cmdRunFromDIR.sublime-build
and open in Sublime Text.Paste the following...
The above will open the current folder but if you want the project directory then there's a whole host of different methods here. Note: That the
&
afterSTART
will then pass on the$file_path variable
which can be changed to any of those below. I couldn't see any documentation for this. It was just trial and error on my behalf and makes sense if you think about it. So, if you try to pass"cmd": ["C:\\\\Windows\\System32\\cmd.exe", "/C START & $file_path"]
to will get anERROR
if the path has any whitespaces in it.For the keyboard shortcut go to
Menu
>Preferences
>Key Bindings
and paste the following code. This shortcut isCTRL+C
,D
.Add
,
at the end of this line if it's not the last line in that file.There's no requirement to restart Sublime Text.
You also access this via
Menu
>Tools
>Build System
>cmdRunFromDIR
.Once this is done
CTRL+B
will run the command also.Useful links: See 1st link below for how to run
.bat
files directly from Sublime Text. Very little modification of the code above.Build System - Sublime Text 3
In Sublime Text 3, how to have shortcuts for “Build and Run” and “Build only” separately like it was in Sublime Text 2
How to Add a Shortcut for Any Command in Sublime Text
Build Systems – Configuration
Just to expand on TomCaps answer, you can also open the command prompt at the root project folder (as was requested in the question), by changing step 3 to:
Create a python file named cmd.py with the following code in the cmd folder created in step 2.
I was looking for the same thing, except on Mac OS X. I also tried the
But I ended up using the
for the following reasons:
The Shell Turtlestein package also has a command for this.
With that package installed, you can type CTRL+SHIFT+ALT+C
(or CMD+SHIFT+ALT+C on mac) to open cmd/terminal in the current file's folder.