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
In the Sublime editor, click on Preferences and select Key Bindings – User. If you want to open command line prompt by command (by ‘cmd’ for example), Add the following context data into Default (Windows).sublime-keymap file. :
For the current user, select Pathin the User variables for {username}section For all users, select Pathin the System variablessection In the Variable valueinput, add an entry with the Sublime Text installation directory. If there is an existing value, add a ;before the Sublime Text directory.
That is all about and you have done. Verify: Now, just test it. Open any program file in the sublime editor and Right-click (context menu). You can see the Cmd menu in Context menu options. Click on it. The command prompt will be opened through which you can compile and run your program.
Version: Dev4.03.23.13.0 Sublime Text includes a command line tool, subl, to work with files on the command line. This can be used to open files and projects in Sublime Text, as well working as an EDITORfor unix tools, such as git and subversion. Setup Windows Mac Linux Usage Configuring as EDITOR Setup
preference
> Browser Packages
in Sublime Text 2.Cmd
in the directory opened in step 1.cmd.py
with the following code in the Cmd
folder created in step 2.import os, sublime_plugin class CmdCommand(sublime_plugin.TextCommand): def run(self, edit): file_name=self.view.file_name() path=file_name.split("\\") current_driver=path[0] path.pop() current_directory="\\".join(path) command= "cd "+current_directory+" & "+current_driver+" & start cmd" os.system(command)
Context.sublime-menu
with the following code in the Cmd
folder created in step 2.[ { "command": "cmd" } ]
Now you can open the Cmd prompt at the current directory in the right-click context menu.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With