📜  在 linux 中设置 sublimeREPL - Shell-Bash 代码示例

📅  最后修改于: 2022-03-11 14:51:42.647000             🧑  作者: Mango

代码示例1
Steps to make Sublime Python Console which is Interactive and Reusable :

1) Install SublimeREPL plugin :
In Top Bar > "Tools" > "Command Palette" > "Package Control: Install Package"
Search for : "SublimeREPL" and install

2) Create Build System :
In Top Bar > "Tools" > "Build System" > "New Build System"

Replace all contents of the file with :
{
    "target": "run_existing_window_command", 
    "id": "repl_python_run",
    "file": "config/Python/Main.sublime-menu"
}
Save the file as "PythonRepl.sublime-build" in the default "user" folder.

3) Settings to make Console interactive and Reusable:
 
|=> Goto "Preferences" > "Browse Packages"
|=> Goto Folder : SublimeRepl
|=> Edit : sublimerepl.py

Replace : 

if view.id() == view_id

With

if view.name() == view_id:

|=> Goto Folder : SublimeRepl/config/Python
|=> Edit : Main.sublime-menu
|=> Under "caption": "Python - RUN current file"
|=> Append : "-i", in "cmd" as : 

        "cmd": ["python", "-u", "$file_basename"],

        "cmd": ["python", "-i", "-u", "$file_basename"],

|=> Add : Before "external_id": "python"

        "view_id": "*REPL* [python]",

|=> Full Code as shown below :

    {"command": "repl_open",
     "caption": "Python - RUN current file",
     "id": "repl_python_run",
     "mnemonic": "R",
     "args": {
        "type": "subprocess",
        "encoding": "utf8",
        "cmd": ["python", "-i", "-u", "$file_basename"],
        "cwd": "$file_path",
        "syntax": "Packages/Python/Python.tmLanguage",
        "view_id": "*REPL* [python]",
        "external_id": "python",
        "extend_env": {"PYTHONIOENCODING": "utf-8"}
        }
    },
    
4) Using :
4.1) Open the Python file that you want to run in Sublime Text.

4.2) In Top Bar > "Tools" > "Build System" > "PythonRepl".

4.3) Build the Python file, by choosing In Top Bar > "Tools" > "Build"