Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save terminal tabs to saved workspace VSCode

Is it possible to save Terminal settings to a workspace? For most of my projects I always have two terminal tabs open. One where I do all of my git work and one where I run gulp tasks. These are two different folders and neither are the project root. When I open a saved workspace it always just opens one tab to the project root.

like image 249
PattyOK Avatar asked Jul 12 '18 18:07

PattyOK


People also ask

How do I save my workspace settings in Visual Studio Code?

Name it whatever you want, then click on "Select Folder". It will appear in the *Visual Studio Code explorer. Now from menu File → Save Workspace As.... Name the workspace and save it wherever you want to keep all your workspaces, (not necessarily where your project folders are).

How do I change the terminal tab in VS Code?

Move to next terminal - Ctrl+PageDown (macOS Cmd+shift+[) Focus terminal tabs view - Ctrl+Shift+\ (macOS Cmd+Shift+\) - Terminal tabs preview.


1 Answers

Look at the Restore Terminals extension. For example, in your settings.json:

 "restoreTerminals.runOnStartup": false,   // true is the default
          // set to false if using a keybinding or command palette

  "restoreTerminals.terminals": [
    {
      "splitTerminals": [
        {
          "name": "git",
          "commands": [
            "cd <your directory>",
            "npm run test"         // your git command(s)
          ]
        }
      ]
    },
    {
      "splitTerminals": [
        {
          "name": "gulp",
          "commands": [
            "cd zip",
            "gulp sass"
          ]
        }
      ]
    }
  ]

will open two terminals, one for your git work and one for the gulp work. They can each take multiple commands.

Example keybinding:

{
  "key": "shift+alt+t",    // whatever keybinding if you wish
  "command": "restore-terminals.restoreTerminals",
},

or you can it run at start-up.

like image 182
Mark Avatar answered Sep 28 '22 16:09

Mark