Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code task to open VS Code's simple browser with a url

I intend to write a task, that first runs a dev server command, and parallely opens VS code's Simple Browser (Command Pallette -> Simple Browser) to the url.

I dont need the task to dynamically get the url from the dev server.

like image 676
Blaine Avatar asked Sep 06 '25 00:09

Blaine


1 Answers

I've managed to make task to open the Simple Browser using input variable

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "open simple browser",
      "command": "${input:openSimpleBrowser}",
      "problemMatcher": []
    }
  ],
  "inputs": [
    {
      "id": "openSimpleBrowser",
      "type": "command",
      "command": "simpleBrowser.show",
      "args": ["https://xkcd.com"]
    }
  ]
}

One thing that I didn't find the documentation of is to find the name of the command. I found the name simpleBrowser.show by chance in VSCode itself. Apparently, you can get the name of each command in the command palette by:

  1. search the command in the palette first
  2. select the Configure Binding cog icon, which will take you to Keyboard Shortcuts
  3. in the search bar, the name of the command will be written, e.g. @command:simpleBrowser.show
  4. you'll only need the name after : for input variable
like image 182
keychera Avatar answered Sep 09 '25 00:09

keychera