compile in sublimeText 3 python code activating a cmd window

4

Maybe my question is not the most accurate but good to explain create a new build system

{
"cmd": ["start", "cmd", "/k", "C:/Users/Jsociety/AppData/Local/Programs/Python/Python36/python.exe", "$file"],
"selector": "source.python",
"shell": true,
"working_dir": "$file_dir"

}

all perfect I get the scripts that I write but I would like to press the enter key to close the cmd window without having to exit () every time I run a script I would like to know if I can place an action modifying the build that you configure to behave like this

everything runs cool but what I want to modify in the build is to stop putting exit () and just press the enter key close the window

    
asked by Vladimir Joel 08.02.2018 в 07:15
source

1 answer

2

One option may be the following:

  • Use shell_cmd instead of cmd which, although it does not automatically escape arguments containing spaces or quoting, is more flexible.

  • Then change cmd /K to cmd /C , the first executes the command and then returns to the prompt , while the second executes the command and ends.

  • Finally, you can concatenate the call to the Python interpreter with a call to set /p that blocks the terminal until Enter is clicked.

The JSON could be something like this:

{
    "shell_cmd": "start cmd /C \"(C:/Users/Jsociety/AppData/Local/Programs/Python/Python36/python.exe \"$file\" || set /p = Failed execution. Press Enter to exit...) && set /p = Successful execution. Press Enter to exit...\"",
    "selector": "source.python",
    "working_dir": "$file_dir"
}
    
answered by 08.02.2018 / 12:45
source