Change VsCode terminal tabs icon and color with the cli

Viewed 1944

I would like to be able to change the color & icon of my terminal tabs & colors with the cli.

enter image description here

This could be the result
enter image description here

The reason of it would be to use the restore terminals extension, and then automatically set the a different icon and color of each terminal.

But I can't find it through the documentation, is it somehow doable?

3 Answers

If someone is still interested, this can be done. At least right now you can specify the profile for the terminal in the extension settings:

"restoreTerminals.terminals": [
    {
      "profile": "Coverage",
      "splitTerminals": [
        {
          "name": "Coverage",
        }
      ]
    },
    {
      "profile": "Server",
      "splitTerminals": [
        {
          "name": "Server",
        }
      ]
    }
  ]

So you can actually create a profile for each terminal you want like so:

"terminal.integrated.profiles.windows": {
    "Coverage": {
      "path": ["D:\\Program Files\\Git\\bin\\bash.exe"],
      "icon": "beaker",
      "color": "terminal.ansiGreen"
    },
    "Server": {
      "path": ["D:\\Program Files\\Git\\bin\\bash.exe"],
      "icon": "server",
      "color": "terminal.ansiMagenta"
    }
  },

And done: Terminals

In your settings.json file you can specify the icon and color of the icon within the profile. For example:

"terminal.integrated.profiles.windows": {
        "PowerShell": {
            "source": "PowerShell",
            "icon": "terminal-powershell"
        },
        "Command Prompt": {
            "path": [
                "${env:windir}\\Sysnative\\cmd.exe",
                "${env:windir}\\System32\\cmd.exe"
            ],
            "args": [],
            "icon": "terminal-cmd"
        },
        "Git Bash": {
            "source": "Git Bash",
            "icon": "terminal-bash", //what icon to use
            "color": "terminal.ansiGreen" //color of icon
        }
    },
"terminal.integrated.defaultProfile.windows": "Git Bash",

Using that extension you linked to yields a result like this (using the example json settings they list in their extension documentation):

Icons

It looks like the extension uses whatever your default terminal profile is (actually looking at its source code, it doesn't even know what the default profile it, is just calls VS Code API commands to spawn new terminals), and applies the settings of said profile, so you will be limited to only the one color/icon.

, The purpose of my question was to be able to change each icon and color, api should be yellow, cloud blue, .... I did update my question to be more precise of what I do try to archive.

If it is doable, that won't be by VSCode itself, but by an extension.

"Assign unique/random color/icon to terminal tab on creation" (microsoft/vscode issue 127951) is clear:

closing as an extension could do it

The OP adds:

to make it doable we first need to understand how to change the color through the api

This is followed by issue 128228 and implemented in PR 130123 "Finalize terminal color API"

Related