Vscode-remote-release: Default to remote when opening VS Code

Created on 23 Jun 2019  路  8Comments  路  Source: microsoft/vscode-remote-release

I've been using the Remote-WSL extension ever since its launch, and it became my default way of using VS Code on Windows - this means that whenever I want to open a new instance, I have to go through the following dance:

  • if I already have a VS Code instance opened, I need to click the remote icon in the corner, a picker opens and I choose the type, then a new window opens.
  • if no window was open, I have to open one, do the same steps as above, then close the first window I opened.

While not _that_ big of a deal, I would very much like to be able to set a remote environment as the default when VS Code starts.

feature-request

Most helpful comment

I was searching the same, be able to make VS Code run in remote WSL mode as default.

I think it would be awesome to have a simple check option, like "Set remote WSL as default opening mode" to let user decide.

Doing so, developers who works primarily with windows environnement can let this option unchecked, but developers who works primarily with linux environnement (such as radu-matei and me) can check this option and save so much time.

In my case, i'm starting using WSL2 Ubuntu to save some disk space and stop wasting time restarting my computer using a dual boot Windows 10 + Ubuntu each time i need to use a windows only application. So, adding this feature will really helps in saving time.

_Edit :_ @radu-matei as a temporary workaround, i created a startup menu link "VS Code Remote WSL" and set its Target to C:\Users\marcv\AppData\Local\Microsoft\WindowsApps\ubuntu.exe run code ~. This allow me, at least, to save a bit time (not needed to launch terminal first, then run code .)

But this doesn't solve this feature request at all, because the real interest of having an option like "Set remote WSL as default opening mode" is to be able to manage all uses only in remote WSL mode, granting us to use all latest up to date packages and dependencies, which are most of time distributed on Linux.

With such a feature, so we could work with an effective, up to date and without duplicates of any kind environment. A dream could become true ^_^

All 8 comments

I mostly use File > Open Recent to reopen remote workspaces.

We're also discussing if 'New Window' should automatically open with a recently opened folder.
Also an idea is to add a Remote WSL: Open Recent... to the remote menu.

I was searching the same, be able to make VS Code run in remote WSL mode as default.

I think it would be awesome to have a simple check option, like "Set remote WSL as default opening mode" to let user decide.

Doing so, developers who works primarily with windows environnement can let this option unchecked, but developers who works primarily with linux environnement (such as radu-matei and me) can check this option and save so much time.

In my case, i'm starting using WSL2 Ubuntu to save some disk space and stop wasting time restarting my computer using a dual boot Windows 10 + Ubuntu each time i need to use a windows only application. So, adding this feature will really helps in saving time.

_Edit :_ @radu-matei as a temporary workaround, i created a startup menu link "VS Code Remote WSL" and set its Target to C:\Users\marcv\AppData\Local\Microsoft\WindowsApps\ubuntu.exe run code ~. This allow me, at least, to save a bit time (not needed to launch terminal first, then run code .)

But this doesn't solve this feature request at all, because the real interest of having an option like "Set remote WSL as default opening mode" is to be able to manage all uses only in remote WSL mode, granting us to use all latest up to date packages and dependencies, which are most of time distributed on Linux.

With such a feature, so we could work with an effective, up to date and without duplicates of any kind environment. A dream could become true ^_^

@radu-matei , @Elundia , I and my colleague found some solution.
In RegEdit go to Computer\HKEY_CLASSES_ROOT\Directory\shell, create new key ('WSL_VSCode', for example) in shell. Give value to (Default) ('Run with WSL Code', for example) and create new string value in this key, name it 'icon' and copy path to icon from VSCode key.
After this create new key inside your new key ('WSL_Code') and name it command. Default value should be:
UPDATED 2
wsl.exe --cd "%V" -- echo $PWD && code .
Universal way to open WSL Code from everywhere.

UPDATED
PowerShell -WindowStyle Hidden -Command "ubuntu run code $('%1' -Replace 'C:','/mnt/c' -Replace '\\','/')"
This command will work for all folders on disk C.

ORIGINAL
powershell.exe -windowstyle hidden -command "ubuntu run code /mnt/c/Users/$(Split-Path $env:userprofile -Leaf )/Desktop/$(Split-Path %1 -Leaf )"
Thereafter you can open folders with right click (select 'Run with WSL Code').

Important! This solution will work ONLY in one folder (in command above it will be currrent user desktop but you can change it). If you know how to fix this you welcome.
And yes, it douesn't work very fast but it works. :)

FWIW, since initially opening this issue, I have been exclusively starting VS Code from WSL itself (code / code-insiders <path-to-directory>), so it is not necessarily still an issue for me personally.

I think adding a documentation note with the above should be enough for people trying to ease their workflow in the future.

I personally see this issue as needing expansion to cover not only Remote-WSL but also Remote-SSH and Remote-Containers. Specifically, in Settings I'd like to have a set of four options:

  1. Default (current machine)
  2. Remote-WSL
  3. Remote-SSH
  4. Remote-Containers

I assume next to each remote would require displaying the list of those endpoints available (e.g. an ssh host a user has set up on their machine launching vscode).

If someone doesn't tackle beforehand, I'll hopefully have time to get involved and submit a PR to fix in June.

Hi all, thank you for a great discussion here!

There is https://github.com/microsoft/vscode-remote-release/issues/120 for auto-connecting to a remote host on startup. From what I can tell, that is the main ask in this thread as well? If that's the case, I'll close this issue to avoid duplicates.

@bamurtaugh , can鈥檛 speak for others, but on my part this was exactly auto-connecting issue.

@BOCbMOU Thanks for the info! I'll go ahead and close this issue as it appears that's the main ask here, but folks can please feel free to let me know if I might be missing or misreading something, and I'd be happy to discuss or revisit this further.

Was this page helpful?
0 / 5 - 0 ratings