Sublime Text 2 - Open CMD prompt at current or project directory (Windows)

后端 未结 5 863
庸人自扰
庸人自扰 2020-12-22 23:46

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         


        
5条回答
  •  眼角桃花
    2020-12-23 00:39

    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:

    1. Create a python file named cmd.py with the following code in the cmd folder created in step 2.

      import os, sublime, sublime_plugin
      class CmdCommand(sublime_plugin.TextCommand):
          def run(self, edit):
              file_name=sublime.active_window().project_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)
      

提交回复
热议问题