GithubHelp home page GithubHelp logo

estruyf / vscode-remote-control Goto Github PK

View Code? Open in Web Editor NEW
17.0 4.0 6.0 2.21 MB

Remote Control your Visual Studio Code - This extension allows you to remotely control Visual Studio Code. Run commands from anywhere you want on your device. The extension allows you to take VSCode automation to the next level.

Home Page: https://marketplace.visualstudio.com/items?itemName=eliostruyf.vscode-remote-control

TypeScript 82.13% JavaScript 17.87%
vscode vscode-extension code extension remote control remote-control

vscode-remote-control's Introduction

Remote Control

Visual Studio Marketplace Number of installs Ratings Buy me a coffee

This extension allows you to remotely control Visual Studio Code. Run commands from anywhere you want on your device. The extension allows you to take VSCode automation to the next level.

In the background it uses websockets in order to listen to commands it should execute in your VSCode instance.

Info: This is a sample of how I use the Remote Control extension in combination with the macOS Raycast app.

Extension Settings

The extension has the following settings which you can use to configure it:

  • remoteControl.enable: enable/disable this extension
  • remoteControl.host: the hostname of the websocket server. Default: 127.0.0.1.
  • remoteControl.port: set the port number for the websocket to start the server
  • remoteControl.fallbacks: an array of port numbers to fallback to if the port is already in use
  • remoteControl.onlyWhenInFocus: allows you to broadcast commands to all VSCode instances and only the one with focus will execute it.

Current port in use

Once the extension starts, it will show the port number in the status bar. This way you can easily see which port is used.

Usage

When you install this extension, it will automatically open a websocket on port 3710. This port can be changed on in the VSCode settings. When you are going to use multiple VSCode sessions at the same time, it is best to configure it on workspace level or use the remoteControl.fallbacks setting to specify fallback ports when the previous one is already in use.

Once installed, you can execute commands for VSCode remotely by calling the Remote Control its websocket. Here is an example how to open the terminal in VSCode:

echo "{ \"command\": \"workbench.action.terminal.new\" }" | websocat ws://localhost:3710

The text you need to pass to the websocket listener is as you can see a stringified JSON object. The object currently consists of:

  • Command: <command-id>

How do I get the command ID?

To get the command ID, open the Command Palette and type Show all commands. This will give you a list with all the available commands.

Behind each command, there is a gear button. When you click on it, it brings you to the shortcut configuration. Where you can right-click on the command and copy its ID.

Feedback / issues / ideas

Please submit your feedback/issues/ideas by creating an issue in the project repository: issue list.

vscode-remote-control's People

Contributors

eluce2 avatar estruyf avatar joshuaeke avatar mqnc avatar tekacs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vscode-remote-control's Issues

Feat: select random port if default port is already taken

I installed the plugin globally, then opened a second VSCode instance to the following error message:

20220818-23:01:15-Selection-001

I did NOT yet configure anything. I would think the extension to use a different port, if it's impossible to use the same port for multiple instances (I expect two instances of VSCode to be two separate environment?). Maybe use a random port without configuration or a range of ports from which is selected?

I assume it would make more sense maybe, to add some form of onboarding when the extension is loaded the first time in a workspace without configuration that explains how its working and tells users to select a specific port or disable the extension in this specific workspace. I know it's hard to tell if a workspace is configured, there is folder config, workspace config, user config... but somehow the extension should help with the initial configuration tasks.

Maybe even add a note to enable this extension only per workspace and then have an onboarding form to set "conscious" values?

Ranting here, I know :) Thanks for the hard work!

PS: also the "configure locally" and "configure globally" buttons irritate me slightly... isn't global config exactly what we don't want so we DON'T have two projects use the same port?

PPS: in the farthest sense what I am trying to say is, that this should be a notification "hey, using port Y because port X is used by another VSCode instance. Go to the docs to find out how to configure this properly".

Question...

I can see one can pass arguments like:

echo "{ \"command\": \"editorScroll\", \"args\": { \"to\": \"up\" } }"  | websocat ws://127.0.0.1:9999

The above command works, but the one below doesn't:

echo "{ \"command\": \"vscode.open\", \"args\": { \"uri\": \"file://some/file.py\" } }"  | websocat ws://127.0.0.1:9999 

The file in question is in the currently opened folder in VSCode. I don't know if it is a matter of escaping the URI. Is there a way to debug the extension? Thanks

Feature Request: Find out which vscode instance is in focus

I am using this extension for voice coding. If I have multiple instances of vscode running, my commands are sent to the one with the default port, while they should be sent to the instance that has the focus.

I see several options to address this:

  • create an option that remote control only accepts commands when the window is in focus, then I can just broadcast commands to the default and all fallback ports
  • reflect the port in the vscode window title, where it can easily be read out
  • make query-able via ws whether an instance has the focus (this would be the most complicated because it needs a ping pong with each instance before every command)

Would any of this be possible? If you have another idea that doesn't involve modifying your source, I am all ears!

Thanks!

Feature request: pair programming on a code-server instance

Hi!

I'm using code-server, basically vscode.dev. I have been looking for a tool so that I can do away with Teamviewer/RustDesk when doing remote pair programming and yours feels like it has the potential.

Basically, multiple devs will connect to the same URL, e.g. https://vscode.example.com where a single instance of VSCode is running.
Let's say there are 3 devs, A, B and C. If A were to move his cursor and start typing, B and C will see the same as what A is seeing on his screen.

Is this something this extension can implement?

Need to execute terminal commands

I would like to be able to use this extension to execute terminal commands using this engine, but it seems this cannot be done with the command option alone. I think you may need an additional branch, maybe something like this?

if (wsData.command === "terminal.execute") {
  let terminal = vscode.window.activeTerminal as vscode.Terminal;

  if (terminal && args) {
    terminal.show(true);
    terminal.sendText(args);
  }
}

Allow for multiple / dynamic ports

Hi love this project! Do you mind changing / adding the use of multiple ports?

I sometimes use multiple vscode instances and the second one tries to use the port, which is obviously already in use.
So extending / converting port: int, to ports: array would be great.

Further, is it possible to then query the used port and inject it in the terminal environment on startup?

So basically what I would like to have is:

ports = [
    42,
    1337
]
// Start instance 1 with port 42
// open terminal with $PORT=42

// Start instance 2 with port 1337
// open terminal with $PORT=1337

Add REMOTE_CONTROL_PORT environment variable to the vscode integrated terminal.

When a new instance of vscode is started and a random port is allocated it can be difficult to know which port is being used.

Please could we have a REMOTE_CONTROL_PORT environment variable set in the integrated terminal with the REMOTE_CONTROL_PORT value.

This is useful for shell scripts that need to execute in the active VScode window.

Here is a PR: #5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.