简体   繁体   English

通过远程 WSL 扩展在 vscode 中使用 WSL bash 与在 Windows 中通过选择作为默认 shell 使用它有何不同?

[英]How is using WSL bash in vscode through the remote WSL extension different from using it by selecting as default shell while in windows?

Before I knew about the remote WSL extension for vscode, I had been using bash in it by selecting it as the default shell from the terminal option.在我了解 vscode 的远程 WSL 扩展之前,我一直在其中使用 bash,方法是从终端选项中选择它作为默认 shell。 What is the advantage of using remote WSL if all I wanted was to just use bash as the default terminal?如果我只想使用 bash 作为默认终端,那么使用远程 WSL 有什么好处?

Hi Rohan and welcome to SO!嗨,罗汉,欢迎来到 SO!

I'll have a shot at answering this, though someone more knowledgeable might have better insight.我将尝试回答这个问题,尽管知识渊博的人可能会有更好的洞察力。

When you load VSCode in windows, it accesses your various PC resources as windows resources.当你在 windows 中加载 VSCode 时,它​​会像 windows 资源一样访问你的各种 PC 资源。 For example your files will be from the windows folder structure.例如,您的文件将来自 windows 文件夹结构。 Even if you use WSL bash as your terminal, VSCode is still acting on a windows basis.即使你使用 WSL bash 作为你的终端,VSCode 仍然在 Windows 的基础上运行。

If you use the remote WSL extension, it leverages VSCodes separation of UI and Backend by remotely starting a VSCode backend in the WSL layer, and connecting the windows UI to that backend ('remotely' although on the same PC).如果您使用远程 WSL 扩展,它会通过在 WSL 层远程启动 VSCode 后端,并将 Windows UI 连接到该后端(“远程”,尽管在同一台 PC 上)来利用 VSCodes 分离 UI 和后端。 Due to running the backend in a linux environment, the files are loaded as linux files and handled via the WSL system, rather than normal windows access.由于在 linux 环境中运行后端,文件作为 linux 文件加载并通过 WSL 系统处理,而不是正常的 windows 访问。

With regard to the question 'What is the advantage?'关于“优势是什么?”这个问题。 I would suggest the advantage is that now instead of having a split between VSCode in windows and command line in WSL, you now have both acting in harmony through WSL.我建议的优点是,现在不是在 Windows 中的 VSCode 和 WSL 中的命令行之间进行拆分,而是通过 WSL 使两者协调一致。 It should provide some benefits (especially when WSL2 hits properly and performance increases) around things not messing in a windows manner on files you are trying to use in a linux way, and just make things feel a bit more connected.它应该提供一些好处(尤其是当 WSL2 正确命中并且性能提高时),围绕在您尝试以 linux 方式使用的文件上不会以 Windows 方式混乱的情况下,并且只是让事情感觉更加紧密。

However if you're using WSL bash just as a command line replacement and not using it for it's linux goodness (though I don't know if this would be the case), there may be less of an advantage.但是,如果您将 WSL bash 仅用作命令行替换,而不是将其用于 linux 的优点(尽管我不知道是否会是这种情况),那么优势可能会减少。

It's a stepping stone to switching to devcontainers, which are really neat.这是切换到开发容器的垫脚石,它非常简洁。

This page might help more, but that's my understanding!这个页面可能有更多帮助,但这是我的理解! https://code.visualstudio.com/docs/remote/wsl https://code.visualstudio.com/docs/remote/wsl

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM