0

使用新的 Windows 终端,可以在选项卡式终端中设置任意 shell,并且它配置了很多,包括 Powershell、Cmd 和 WSL(在我的情况下是 Ubuntu 20.04,尽管我认为如果我安装它们会更多)。

但是,我希望能够设置一个 Python“shell”,以加载 Ubuntu WSL 实例,然后自动让它在其中为我运行 Python。目前,我必须启动 Ubuntu,然后从那里手动运行 Python。我的设置是:

{
    "guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
    "hidden": false,
    "name": "Ubuntu-20.04",
    "startingDirectory": "//wsl$/Ubuntu-20.04/home/pax",
    "source": "Windows.Terminal.Wsl"
}

由于我经常将 Python 用于非常快速的“不”脏 REPL 事情,我宁愿能够让它在选项卡中自动启动。有没有办法配置 Windows 终端来做到这一点?对于它的价值,我使用的是 1.2 预览版。

4

1 回答 1

1

使用命令wsl执行内部程序。

{
    "acrylicOpacity" : 0.75,
    "closeOnExit" : true,
    "colorScheme" : "Campbell",
    "commandline" : "wsl.exe -d Ubuntu -e python3",
    "cursorColor" : "#FFFFFF",
    "cursorShape" : "bar",
    "fontFace" : "Consolas",
    "fontSize" : 10,
    "guid" : "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
    "historySize" : 9001,
    "icon" : "ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png",
    "name" : "Python",
    "padding" : "0, 0, 0, 0",
    "snapOnInput" : true,
    "startingDirectory" : "%USERPROFILE%",
    "useAcrylic" : true
},

这是命令参考。

https://docs.microsoft.com/en-us/windows/wsl/reference

于 2020-08-02T08:19:58.813 回答