我可以使用code /path/to/folder
来启动VS Code并打开一个本地文件夹。是否有可能通过在命令行中指定机器和文件夹来打开远程机器上的文件夹(通过Remote SSH扩展)?
我可以使用code /path/to/folder
来启动VS Code并打开一个本地文件夹。是否有可能通过在命令行中指定机器和文件夹来打开远程机器上的文件夹(通过Remote SSH扩展)?
在Linux或Mac终端的CLI中:
code --folder-uri=vscode-remote://ssh-remote+<主机名><绝对路径>
类似这样:
code --folder-uri=vscode-remote://ssh-remote+centos8stream.local/home/guillaume/workspace/
在我的~/.ssh/config
文件中,我有:
Host centos8stream.local
Hostname 10.41.11.69
User guillaume
在我的终端中,我可以通过ssh centos8stream.local
连接到我的服务器。
然后我可以直接打开远程服务器上的vscode:
code --folder-uri=vscode-remote://ssh-remote+centos8stream.local/home/guillaume/workspace/
我甚至在~/.zshrc
文件中创建了一个别名函数。
function rcode() { code --folder-uri=vscode-remote://ssh-remote+$1/home/guillaume/$2 }
rcode centos8stream.local workspace/my_project
function rcode() {code --remote ssh-remote+$1 $2}
基于 https://dev59.com/XL7pa4cB1Zd3GeqPqg1L - p8me将远程文件夹挂载到您的开发工作站并在VSCode中打开。