githubterminalcodespaces

Github Codespaces start terminals with command on startup


does anyone know a way to configure Github codespaces to run automatic multiple terminals with commands (eg. "npm start") on startup?

I already tried the VS-Code extension "Terminal Manager" with configured terminals.json file, but it works just in normal VS-Code. Not in Codespaces.

Thanks in advance


Solution

  • You can use postCreateCommand

    This command is the last of three that finalizes container setup when a dev container is created.

    If you have one script you can run after container created with this syntax:

    {
      "postCreateCommand": "npm start"
    }
    
    // or
    
    {
      "postCreateCommand": ["npm", "start"]
    }
    

    if you have multiply command you can separate commands with &&:

    {
      "postCreateCommand": "npm install && npm start"
    }
    

    Devcontainer refernce
    Devcontainer Lifecycle scripts
    String vs array in devcontainer.json
    Github issue