31

Is it possible to configure User Settings to have the Integrated Terminal to start automatically when opening Visual Studio Code?

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
Isak La Fleur
  • 4,428
  • 7
  • 34
  • 50
  • 1
    Mine always open the `Integrated Terminal` whenever I start my VSCode but I didn't notice anything different in my `USER SETTINGS`. Which OS are you using? – ian0411 Aug 30 '17 at 15:20
  • I'm using Mac OS Sierra. – Isak La Fleur Sep 01 '17 at 14:31
  • Man, I guess this is probably OS issue but not sure. You can also install `Shell Launcher` since they have some cool features that may help you out. Also, I noticed that I have `PowerShell` installed on my machine. You can install that since it looks like it has some abilities to open the terminal automatically (maybe not the one you want). Sorry couldn't be more helpful... – ian0411 Sep 01 '17 at 15:19

5 Answers5

36

There is now an extension that lets you set terminals on startup, and even works with split terminal views!

https://marketplace.visualstudio.com/items?itemName=EthanSK.restore-terminals

ps i wrote it

Ethan SK
  • 736
  • 8
  • 12
15

As of VS Code v1.45.0, the experimental configuration mentioned in this other answer should now be the default behavior for VS Code. Just make sure to save your files/folders in a workspace. See the What is a VS Code "workspace"? section of the VS Code docs.

VS Code remembers the last state of your workspace and restores it. If I have the Integrated Terminal panel opened before I closed the window, it gets reopened when I reload or reopen the workspace (I can't seem to find the setting for this though). So basically, the Integrated Terminal is already auto displayed. (I use Ubuntu 18 and macOS 10.15.)

If you have a specific terminal setup (ex. multiple terminals opened to different directories, python envs, workspaces, etc.), you could check out Terminals Manager which is for "setting-up multiple terminals at once" and can be configured to auto-run on startup.

You just need to add a terminals.json file in your workspace (under .vscode) with something like this, and set autorun to true. This would auto-run the extension's Terminals: Run command on startup to auto-load your terminals.

{
    "autorun": true,
    "autokill": true,
    "terminals": [
        {
            "name": "GIT",
            "description": "For running git commands",
            "open": true,
            "focus": true,
            "commands": [
                "pwd",
                "git fetch -v"
            ]
        },
        {
            "name": "BUILD",
            "description": "For running build commands",
            "open": true,
            "focus": false,
            "commands": [
                "cd apps",
                "./clean.sh"
            ]
        },
        {
            "name": "SCRIPTS",
            "description": "For running python commands",
            "open": true,
            "focus": false,
            "commands": [
                "source $VENV_DIR/test-py38/bin/activate",
                "python -V"
            ]
        },
    ]
}
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
6

The following has worked for me:

// Whether to restore terminal sessions for the workspace automatically when launching VS Code. This is an experimental setting; it may be buggy and could change in the future.

Paste the below in your user settings:

"terminal.integrated.experimentalRestore": true

coutureCoder
  • 61
  • 1
  • 3
6

The Tasks feature is the current recommended way to handle this and worked for me. See Automating launching of terminals in the VS Code documentation.

Welt Fahr
  • 492
  • 5
  • 8
  • I want to use this method but the problem is that tasks.json is added to the repository on commit and I don't want to share these tasks with other developers. It is mentioned in the documentation : This file could be committed to the repository to share with other developers or created as a user task via the workbench.action.tasks.openUserTasks command. I don't know much about vscode commands . Can you help me out? – Urooj Sep 29 '22 at 04:59
  • 1
    @Urooj: You can add tasks.json to your .gitignore file. – Welt Fahr Sep 29 '22 at 10:02
  • That is not an option. Are there any other alternatives available? What about this line in the documentation that I've mentioned above – Urooj Sep 30 '22 at 06:40
  • If your question is about workbench.action.tasks.openUserTasks: This is available through the menu View > Command Palette. Paste and execute the command there, then choose Others. – Welt Fahr Oct 01 '22 at 07:10
1

Starting with VSCode 1.54 (Feb. 2021), this should be supported by default.
See:

Restoring terminal UI state

On window reload, the UI state of the reconnected terminals will be restored, displaying the active tab.
For each tab, the split dimensions and active terminal will remain the same.

Here: In a local window, two split terminals are created and resized.
On reload, the layout appears unchanged.

https://media.githubusercontent.com/media/microsoft/vscode-docs/vnext/release-notes/images/1_54/local-terminal-reconnection.gif

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    Unfortunately, it does not really solve the question raised by TS. He mentions "on start of the VSCode". The enhancement u mention won't work if u restart VsCode (not window reload). – Nick Wills Oct 23 '21 at 04:24
  • 1
    @Bruce I agree. This is still not fully supported. – VonC Oct 23 '21 at 19:58