The VS Code CLI does not support this AFAIK.
My current workaround is to use code
to open a workspace normally, then use extensions that trigger on VS Code startup (when the window opens) to create my terminals and runs commands on them.
There are a couple of these extensions, but personally I use Terminals Manager.
Create and save a workspace (ex. myapp.code-workspace)
On your workspace, create a .vscode/terminals.json file
Define your terminals in the terminals.json file (refer to the extension's page for the syntax). For example, let's say I want to have 1 terminal that will auto-run npm run start
and 1 terminal that does git fetch
:
{
"autorun": true,
"terminals": [
{
"name": "NPM",
"description": "For NPM commands",
"focus": true,
"commands": [
"cd myapp",
"npm run start"
]
},
{
"name": "GIT",
"description": "For GIT commands",
"focus": false,
"command": "git fetch -v"
}
]
}
When you do code myapp.code-workspace
that should open VS Code and open the defined terminals (with the focus on the terminal with focus: true
:
I like this better even if there's a code --option
to do this, because if I open VS Code "manually" (i.e. by clicking its icon from the dock), then it will also do the same thing. I won't need a separate config/setup.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…