VSCode: 如何在不同目录下启动时打开两个终端
VSCode: How to open two terminals on startup with different directories
我想要在启动时(在文件夹打开时)两个终端。
这些应该以不同的目录开始,并且应该处于拆分模式。这可能吗?
我目前在 tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"presentation": {
"echo": false,
"reveal": "always",
"focus": false,
"panel": "dedicated",
"showReuseMessage": true
},
"tasks": [
{
"label": "Create terminals",
"dependsOn": [
"First",
"Second"
],
// Mark as the default build task so cmd/ctrl+shift+b will create them
"group": {
"kind": "build",
"isDefault": true
},
// Try start the task on folder open
"runOptions": {
"runOn": "folderOpen"
}
},
{
// The name that shows up in terminal tab
"label": "First",
// The task will launch a shell
"type": "shell",
"command": "/bin/bash; cd /var/fpwork/",
// Set the shell type
// Mark as a background task to avoid the spinner animation on the terminal tab
"isBackground": true,
"problemMatcher": [],
// Create the tasks in a terminal group
"presentation": {
"group": "my-group"
}
},
{
"label": "Second",
"type": "shell",
"command": "/bin/bash; cd /var/",
"isBackground": true,
"problemMatcher": [],
"presentation": {
"group": "my-group"
}
}
]
}
这将以拆分模式打开两个终端,但如何为它们指定不同的文件夹?
行数
"command": "/bin/bash; cd /var/fpwork/"
和
"command": "/bin/bash; cd /var/"
似乎忽略了 cd
命令。如何指定终端文件夹?
对我有用的是
"command": "/bin/bash --rcfile <(echo '. ~/.bashrc; cd /var')"
见How to invoke bash, run commands inside the new shell, and then give control back to user?
我想要在启动时(在文件夹打开时)两个终端。
这些应该以不同的目录开始,并且应该处于拆分模式。这可能吗?
我目前在 tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"presentation": {
"echo": false,
"reveal": "always",
"focus": false,
"panel": "dedicated",
"showReuseMessage": true
},
"tasks": [
{
"label": "Create terminals",
"dependsOn": [
"First",
"Second"
],
// Mark as the default build task so cmd/ctrl+shift+b will create them
"group": {
"kind": "build",
"isDefault": true
},
// Try start the task on folder open
"runOptions": {
"runOn": "folderOpen"
}
},
{
// The name that shows up in terminal tab
"label": "First",
// The task will launch a shell
"type": "shell",
"command": "/bin/bash; cd /var/fpwork/",
// Set the shell type
// Mark as a background task to avoid the spinner animation on the terminal tab
"isBackground": true,
"problemMatcher": [],
// Create the tasks in a terminal group
"presentation": {
"group": "my-group"
}
},
{
"label": "Second",
"type": "shell",
"command": "/bin/bash; cd /var/",
"isBackground": true,
"problemMatcher": [],
"presentation": {
"group": "my-group"
}
}
]
}
这将以拆分模式打开两个终端,但如何为它们指定不同的文件夹? 行数
"command": "/bin/bash; cd /var/fpwork/"
和
"command": "/bin/bash; cd /var/"
似乎忽略了 cd
命令。如何指定终端文件夹?
对我有用的是
"command": "/bin/bash --rcfile <(echo '. ~/.bashrc; cd /var')"
见How to invoke bash, run commands inside the new shell, and then give control back to user?