I want on startup (on folder open) two terminals.
These should start with different directories and should be in split mode. Is this possible?
I have this currently in 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"
}
}
]
}
This opens two terminals in split mode, but how can I specify different folders for them? The lines
"command": "/bin/bash; cd /var/fpwork/"
and
"command": "/bin/bash; cd /var/"
just seem to ignore the cd
command. How to specify the terminal folders?
CodePudding user response:
The thing that worked for me is
"command": "/bin/bash --rcfile <(echo '. ~/.bashrc; cd /var')"
See How to invoke bash, run commands inside the new shell, and then give control back to user?