Wednesday, February 11, 2015

Execute python in an external terminal in sublime

Open $HOME/.config/sublime-text-2/Packages/User/Python.sublime-build
and write.
{
    "cmd": ["python", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "working_dir": "${file_path}",
    "selector": "source.python",

    "variants":
    [
        {
            "name": "Run",
            "cmd": ["gnome-terminal", "-x", "bash", "-c", "python '$file'; echo -e \"\n\nPress any key to exit\"; read"],
            "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
            "working_dir": "${file_path}",
            "selector": "source.python"
        }
    ]
}
you may either use the second line for using internal build terminal or the first line for external terminal.

No comments: