Vscode(code.exe)命令行参数可通过SSH立即打开远程工作区文件夹 [英] Vscode (code.exe) command line arguments to immediately open a remote workspace folder over SSH
问题描述
如果我想在C:\下的常规本地文件夹中打开工作区,则只需执行以下命令即可:
If I want to open a workspace on a regular local folder under C:\ I can just execute the command:
code.exe C:\the-local-workspace-folder
是否存在用于打开远程SSH工作区的等效命令?
Is there any equivalent command for opening remote SSH workspaces?
我希望能够使用键盘启动器来打开它们,而不是需要在vscode的内部菜单中随意打开它们.
I want to be able to use my keyboard launcher to open them, rather than needing to open them the fiddly way in the internal menus inside vscode.
所以我需要一个常规的系统命令才能执行此操作.
So I need a regular system command to be able to do this.
我在这里浏览了命令行参数: https://code.visualstudio.com/docs/editor/命令行-但根本找不到有关远程工作区的任何信息.
I've looked through the command line arguments here: https://code.visualstudio.com/docs/editor/command-line - but can't find anything about remote workspaces at all.
我也尝试过以下命令:
code.exe username@hostname.example.com:/workspace-folder
code.exe username@hostname.example.com/workspace-folder
...但是他们对此不起作用.
...but they don't work for this.
推荐答案
This looks like a recent fix, according to the issue tracking here. I've tested with my own settings, and this works:
"C:\Users\myusername\AppData\Local\Programs\Microsoft VS Code\Code.exe" \
--remote ssh-remote+myubuntumachine /home/myusername/myprojectdirectory
myubuntumachine
应该是 CTRL + SHIFT + P
/Remote SSH上SSH配置文件中 Host myubuntumachine
中给出的名称:打开配置文件...
The myubuntumachine
should be the name given in the Host myubuntumachine
in the SSH config file on CTRL+SHIFT+P
/Remote SSH: Open Configuration File...
(实际上,在我的机器上,我没有机器名称,但是有某种哈希值,尽管两者都可以.)
(Actually, on my machine I don't have the machine name, but some sort of hash value, although either works.)
这篇关于Vscode(code.exe)命令行参数可通过SSH立即打开远程工作区文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!