The WCMD extension provides a WebSocket interface for executing commands within Visual Studio Code. While designed to complement the web app at http://cmdkeys.github.io, it offers a flexible tool that can be used for various custom purposes. The interface is open to third-party integrations and is distributed under an open-source license.
By default, the WebSocket server listens on port 5813. Once connected, the server offers two primary functions:
- Executing VS Code Commands: Run any command available in VS Code.
- Accessing the Local Terminal: Execute terminal commands and optionally return output or open a new terminal tab within the VS Code interface.
To explore the full list of available VS Code commands, visit the VS Code Command Guide.
To start, connect to the WebSocket server.
Example local IP: 192.168.1.203
You can test the WebSocket functionality using this tool: WebSocket Test Page.
To connect locally, use the WebSocket URL ws://localhost:5813.
On systems like Linux, you may need to open port 5813. You can check port availability with the following command:
netstat -na | grep :5813
# OPEN THE PORT WITH UFW
sudo ufw allow 5813/tcp
To execute a VS Code command, send a JSON message like the following after establishing a connection:
{"vscodeCommand": "vscode.newWindow"}This will open a new VS Code window.
To run terminal commands, send a message specifying the command and an optional terminal name:
{"terminalCommand": "ls -p", "terminalName": "List all files"}This will execute the ls -p command in a new terminal tab titled List all files.
To execute a command and return the result in the WebSocket response, use:
{"commandWithReturn": "ls -p"}This will return the result of the ls -p command in the response message.
Example response:
- Initial release with basic WebSocket interface functionality.
- Supported features:
- Execute VS Code commands.
- Run terminal commands.
- Retrieve command output.
- Update port number: Change the WebSocket server's port.
- Close WebSocket connections: Disable connections on the current port.
- Display settings: View and modify WebSocket server settings.
author website : https://bueltan.github.io/




