Search code examples
visual-studio-codecommand-linevscode-remote

Vscode (code.exe) command line arguments to immediately open a remote workspace folder over SSH


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

Is there any equivalent command for opening remote SSH workspaces?

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.

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.

I've also tried commands like:

code.exe [email protected]:/workspace-folder
code.exe [email protected]/workspace-folder

...but they don't work for this.


Solution

  • 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
    

    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.)