0

I am trying to automate this task: when VSCode is launched -> open up a terminal and execute "ls -l" in the same terminal window. I have tried the "sequential" property as well as the "Depends on" property, but it still isn't working. This is what my file looks like right now:

{
    "version": "2.0.0",
    "presentation": {
      "echo": false,
      "reveal": "always",
      "focus": false,
      "panel": "shared",
      "showReuseMessage": true
    },
    "tasks": [
      {
        "label": "Create terminal",
        "dependsOrder": "sequence",
        "dependsOn": [
          "First",
          "List files"
        ],
        // Mark as the default build task so cmd/ctrl+shift+b will create them
        "group": {
          "kind": "build",
          "isDefault": true
        },
        "presentation": {
            "panel": "shared",
        },
        // 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",
        "args": [
            "-l"  // login shell for bash
        ],
        // 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",
          "panel": "shared"
        }
      },
      {
            "label": "List files",
            "type": "shell",
            "command": "ls -l",
            "isBackground": false,
            "problemMatcher": [],
            "presentation": {
                "group": "my-group",
                "panel": "shared",
                "reveal": "silent"
            }
      }
    ]
  }

Can anyone help, I've been stuck and there seems to be nothing working.

  • why the bash login shell? Why not just select bash as the default integrated terminal profile for the workspace? And why merge the two tasks and just run a temporary bash shell that just runs `ls -l` and then exits? – starball Mar 17 '23 at 23:09

0 Answers0