[英]How to open a remote folder from command line in VS Code?
I can start VS Code to open a local folder using code /path/to/folder
.我可以启动 VS Code 以使用
code /path/to/folder
打开本地文件夹。 Is it possible to open a folder on a remote machine (via the Remote SSH extension) by specifying the machine and folder on the command line?是否可以通过在命令行上指定机器和文件夹来打开远程机器上的文件夹(通过 Remote SSH 扩展名)?
From the cli on linux or mac terminal:从 linux 或 mac 终端上的 cli:
code --folder-uri=vscode-remote://ssh-remote+<HOSTNAME><ABSOLUTE_PATH>
Something like:就像是:
code --folder-uri=vscode-remote://ssh-remote+centos8stream.local/home/guillaume/workspace/
In my ~/.ssh/config
file I have:在我的
~/.ssh/config
文件中,我有:
Host centos8stream.local
Hostname 10.41.11.69
User guillaume
In my terminal I can ssh to my server doing ssh centos8stream.local
在我的终端中,我可以通过
ssh centos8stream.local
ssh 到我的服务器
Then I can open vscode on my remote server directly:然后我可以直接在我的远程服务器上打开 vscode:
code --folder-uri=vscode-remote://ssh-remote+centos8stream.local/home/guillaume/workspace/
I even created an alias function in my ~/.zshrc
file我什至在我的
~/.zshrc
文件中创建了一个别名函数
function rcode() { code --folder-uri=vscode-remote://ssh-remote+$1/home/guillaume/$2 }
Then I just type然后我只需输入
rcode centos8stream.local workspace/my_project
Mount the remote folder in your dev box and open it in VSCode.将远程文件夹安装到您的开发箱中,然后在 VSCode 中打开它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.