Spartian
Spartian

Reputation: 1

How to run Python scripts in cmd using sublime build system (Sublime Text)?

I'm trying to run python scripts through the sublime build system (Sublime Text). I want built to start terminal, execute the program and wait till press any keys.

{
    "shell_cmd": "start cmd.exe @cmd /c python -u \"$file\" && echo. && pause",
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.python",
    "shell": "true"
}

The above code executes but it terminates as soon as it completes even though pause is added. Using /k terminal stays on screen but then we have manually close it instead of pressing any key.

How to configure shell script so that it will run the code in terminal and end when a key is pressed.

Upvotes: 0

Views: 1517

Answers (2)

Aditya Singh
Aditya Singh

Reputation: 1

As per your requirement, it would be:

    {
    "shell_cmd": "start cmd.exe /c \"python \"$file\" && pause\"",
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.python",
    "shell": "true"
}

Upvotes: 0

Elton da Mata
Elton da Mata

Reputation: 308

python -i works fine.

{
    "shell_cmd": "start cmd.exe /c python -i \"$file\"",
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.python",
    "shell": "true"
}

Upvotes: 1

Related Questions