Marcell
Marcell

Reputation: 496

Is there a way to access VSCode workspace from desktop shortcut?

I have a very basic setup such as a Raspberry Pi set up as a local web development server which I access with SSH keys (passphrase is configured automatically with SSH Agent service) and this is where I store my project. Now I have a certain Workspace there with some custom configurations and other settings.

I have tried to search in Google to quick access it, but found no way so far. In short, I would like to access this workspace with a desktop shortcut on the windows, which will open this workspace for me in VS Code, so I do not need to open VS Code and access this workspace manually.

Is there a way to access VSCode workspace from desktop shortcut?

Any help is very welcome!

Upvotes: 4

Views: 1963

Answers (2)

ClassicWreck
ClassicWreck

Reputation: 1

This leads to VS Code opening up with a remote connection like we want.

It can also leave a useless console window open that can be closed once VS Code launches, but the window stays open. Making the shortcut should produce a shell script. You can then go in and edit the script to close the window.

Not everyone has this issue though but if you do, it's an easy fix, modify a line in the script.

Upvotes: -1

carlfriedrich
carlfriedrich

Reputation: 4093

You can use the --folder-uri argument to code to open an SSH workspace folder (i.e. a single-folder workspace):

--folder-uri vscode-remote://ssh-remote+<your-hostname><your-folder>

E.g. if the hostname of your Raspberry Pi is rpi and your workspace is located in /home/myuser/workspace, open VS Code as follows:

code --folder-uri vscode-remote://ssh-remote+rpi/home/myuser/workspace

If you want to open a multi-root workspace, you need to include the workspace file at the end of the path as follows:

code --folder-uri vscode-remote://ssh-remote+rpi/home/myuser/workspace-folder/workspace-file-name.code-workspace

If code is in your PATH, using this line as target for your desktop shortcut should do the trick.

Alternatively, to have the VS Code icon on your shortcut, use the complete path to your code.exe, e.g.:

"C:\Users\myuser\AppData\Local\Programs\Microsoft VS Code\Code.exe" --folder-uri vscode-remote://ssh-remote+rpi/home/myuser/workspace

Upvotes: 2

Related Questions