[英]Open remote folder in local VSCode like "code ."in WSL2
Is it possible to use $ code.
是否可以使用
$ code.
in remote server ssh session just like I do in WSL
when I want to open current working directory in remote host in local VSCode?在远程服务器 ssh session 中,就像我在
WSL
中一样,当我想在本地 VSCode 中打开远程主机中的当前工作目录时?
ADDENDUM: In local WSL, I can issue $ code.
附录:在本地 WSL 中,我可以发出
$ code.
and that would open the current directory in VSCode which is installed on Windows 10.这将打开安装在 Windows 10 上的 VSCode 中的当前目录。
I am trying to get the same behavior in another remote Linux which I have connected to remotely through ssh
.我试图在另一个远程 Linux 中获得相同的行为,我已通过
ssh
远程连接。 So when I am on that remote machine and issue $ code.
因此,当我在那台远程机器上并发出
$ code.
it would open that directory in VSCode installed on local window.它将在本地 window 上安装的 VSCode 中打开该目录。
I don't imagine this would be simple to do but I certainly share your desire to want to be able to do it.我不认为这很容易做到,但我当然和你一样希望能够做到这一点。
Here's an explanation of why it doesn't work, and a hint at why it's probably quite a difficult thing to setup:以下是它为什么不起作用的解释,以及为什么它可能很难设置的提示:
The way code.
方式
code.
works from WSL (or PowerShell) is by launching VS Code in the given directory (passed as the first argument as the dot). WSL(或 PowerShell)的工作方式是在给定目录中启动 VS Code(作为第一个参数作为点传递)。
When you run code
from WSL it uses wslpath
to convert the path to the Windows accessible one, and the WSL magic executes code.exe
(which is, after all, a Windows binary and not a Linux one) in Windows with the WSL path ( \\wsl$...
); When you run
code
from WSL it uses wslpath
to convert the path to the Windows accessible one, and the WSL magic code.exe
(which is, after all, a Windows binary and not a Linux one) in Windows with the WSL path ( \\wsl$...
);
In order for this to work you need to achieve three things:为了使它起作用,您需要实现三件事:
code.exe
on your local machine, but from your remote terminalcode.exe
,但从远程终端执行A couple of ideas you could play with if you wanted to try and implement it:如果您想尝试实现它,可以使用一些想法:
vscode://
URL for you to click (or find a way to get your client to auto-load it).vscode://
URL 供您单击(或找到让您的客户端自动加载它的方法)。 Just some musings, It's not something I need enough to put any effort into it.只是一些沉思,这不是我需要付出任何努力的东西。 but I came across your question looking for something else and found it interesting, Hope that's helpful to anybody, any thoughts/feedback is welcome!
但我在寻找其他东西时遇到了你的问题,发现它很有趣,希望这对任何人都有帮助,欢迎任何想法/反馈!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.