【问题标题】:Change VsCode terminal tabs icon and color with the cli使用 cli 更改 VsCode 终端选项卡图标和颜色
【发布时间】:2022-03-15 20:14:02
【问题描述】:

我希望能够使用 cli 更改终端选项卡和颜色的颜色和图标。

这可能是结果

原因是使用restore terminals扩展,然后自动为每个终端设置不同的图标和颜色。

但是我通过文档找不到它,它是否可行?

【问题讨论】:

  • 你的意思是like this
  • @TimothyG。没错,我确实更新了我的问题

标签: visual-studio-code


【解决方案1】:

如果有人仍然感兴趣,可以这样做。 至少现在您可以在扩展设置中指定终端的配置文件:

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

因此,您实际上可以像这样为每个终端创建配置文件:

"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"
    }
  },

然后完成: Terminals

【讨论】:

  • 谢谢回答,也看到这是可行的,这个extension 已经实现了这个功能
【解决方案2】:

在您的 settings.json 文件中,您可以指定配置文件中图标的iconcolor。例如:

"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",

使用您链接到的扩展会产生这样的结果(使用他们在扩展文档中列出的示例 json 设置):

看起来扩展使用你的默认终端配置文件(实际上查看它的源代码,它甚至不知道它的默认配置文件,只是调用VS Code API commands to spawn new terminals),并应用所述配置文件的设置,因此您只能使用一种颜色/图标。

【讨论】:

  • 谢谢您的回答,我的问题的目的是能够更改每个图标和颜色,api应该是黄色,云蓝色,....我确实更新了我的问题更准确我所做的尝试存档。
【解决方案3】:

,我的问题的目的是能够更改每个图标和颜色,api 应该是黄色,云蓝色,....我确实更新了我的问题,以更准确地说明我尝试归档的内容。

如果可行,那将不是 VSCode 本身,而是通过扩展。

“在创建时将唯一/随机颜色/图标分配给终端选项卡”(microsoft/vscode issue 127951)很明确:

作为扩展关闭可以做到

OP 补充说:

要使其可行,我们首先需要了解如何通过 api 更改颜色

这之后是issue 128228,并在PR 130123 "Finalize terminal color API"中实现

【讨论】:

  • 添加随机颜色当然可以通过扩展来完成。而且,事实上,我希望它由restore terminal 插件完成。但要使其可行,我们首先需要了解如何通过 api 更改颜色,所以我认为拒绝该特定功能请求不是我问题的正确答案,但我可能在这里遗漏了一些东西 :)跨度>
  • @RaphaëlBalet 将 issue 128228PR 130123
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-03-15
  • 1970-01-01
  • 2019-03-12
  • 2016-04-06
  • 1970-01-01
  • 2016-06-05
  • 1970-01-01
相关资源
最近更新 更多