简体   繁体   English

VS Code 端子颜色很乱

[英]VS Code terminal colors are screwy

I'm using the default theme.我正在使用默认主题。 The terminal's colors are impossible to read, make no sense, and are inconsistent.终端的颜色无法阅读、没有意义并且不一致。 I've tried switching themes but they're terrible in all the themes.我尝试过切换主题,但它们在所有主题中都很糟糕。

Here's what it looks like in the default.这是默认情况下的样子。 Are you able to read my yellow input against the gray background?你能在灰色背景下阅读我的黄色输入吗? And why isn't there a black background everywhere?为什么不是到处都是黑色背景? Powershell 终端窗口

I realize there are settings that can manually set the fore/background colors.我意识到有些设置可以手动设置前景色/背景色。 But I'm thinking something is broken for me because of how screwy the terminal behaves.但是我认为由于终端的行为方式有问题,我觉得有些东西坏了。

For example, here's what I see when I first start the terminal, type a bunch of stuff, backspace to delete half of it, resize the terminal pane, then delete some more.例如,这是我第一次启动终端时看到的内容,输入一堆东西,退格删除一半,调整终端窗格的大小,然后再删除一些。 Notice how some of the deleted spaces have yellow and some have gray.注意一些被删除的空间是黄色的,有些是灰色的。 Also notice how the area where the CWD would be shown is all black.还要注意显示 CWD 的区域是如何全黑的。 初始视图

Here are the contents of my settings.json file:这是我的settings.json文件的内容:

{
    "window.zoomLevel": 0,
    "git.enableSmartCommit": true,
    "workbench.startupEditor": "newUntitledFile"
}

What needs fixing, and how?什么需要修复,如何修复?


Edit:编辑:

Just to satisfy your curiosity, I added this to my settings.json file:为了满足您的好奇心,我将其添加到我的settings.json文件中:

"workbench.colorCustomizations": {
    "terminal.foreground": "#ffffff",
    "terminal.background": "#000000"
}

No joy:不开心: 丑东西还在

There might be something wrong in your console settings, you might want to remove the content of HKCU\Console in your registry.您的控制台设置可能有问题,您可能希望删除注册表中 HKCU\Console 的内容。 Save it before, obviously, but there shouldn't be any side effect: it'll just be recreated with the default settings.显然,之前保存它,但不应该有任何副作用:它只会使用默认设置重新创建。

Okay, so here's a list of all possible settings that you could tweak in your terminal window colorscheme: ( source )好的,这是您可以在终端窗口颜色方案中调整的所有可能设置的列表:( 来源

    "workbench.colorCustomizations": {
      "terminal.background":"#1D2021",
      "terminal.foreground":"#A89984",
      "terminalCursor.background":"#A89984",
      "terminalCursor.foreground":"#A89984",
      "terminal.ansiBlack":"#1D2021",
      "terminal.ansiBlue":"#0D6678",
      "terminal.ansiBrightBlack":"#665C54",
      "terminal.ansiBrightBlue":"#0D6678",
      "terminal.ansiBrightCyan":"#8BA59B",
      "terminal.ansiBrightGreen":"#95C085",
      "terminal.ansiBrightMagenta":"#8F4673",
      "terminal.ansiBrightRed":"#FB543F",
      "terminal.ansiBrightWhite":"#FDF4C1",
      "terminal.ansiBrightYellow":"#FAC03B",
      "terminal.ansiCyan":"#8BA59B",
      "terminal.ansiGreen":"#95C085",
      "terminal.ansiMagenta":"#8F4673",
      "terminal.ansiRed":"#FB543F",
      "terminal.ansiWhite":"#A89984",
      "terminal.ansiYellow":"#FAC03B"
    }

Now for me, the colors of folder names was too bright over an even brighter background color that highlighted them and I couldn't read squat (that's because of my VSCode theme called NightOwl -- :P Sarah) so I thought (wrongly) to change terminal.background and terminal.foreground properties but that refer to the entire rendered window of the terminal.现在对我来说,文件夹名称的颜色在突出显示它们的更亮的背景颜色上太亮了,我无法阅读蹲下(这是因为我的 VSCode 主题称为 NightOwl - :P Sarah)所以我想(错误地)更改terminal.backgroundterminal.foreground属性,但它们指的是终端的整个渲染窗口。

Because these properties are actually named after Ansi Escape Codes , what I was actually looking for were these properties: terminal.ansiBlue for folder name text color and terminal.ansiGreen for folder name background highlight color.因为这些属性实际上是以Ansi Escape Codes命名的,所以我真正要寻找的是这些属性: terminal.ansiBlue用于文件夹名称文本颜色,而terminal.ansiGreen用于文件夹名称背景突出显示颜色。

As soon as I tweaked those, my terminal was good to go.一旦我调整了这些,我的终端就很好了。 The way to do it is to just set all these settings and start removing or changing them to see which is which for your preference.这样做的方法是设置所有这些设置并开始删除或更改它们以查看哪个是您的偏好。 K Thx Bye再见

Also beware that terminal.ansiGreen is used by git diff as a color to show additions.还要注意 git diff 使用terminal.ansiGreen作为颜色来显示添加。

There are two solutions.有两种解决方案。 Xavier's solution works, and mklement0's comment was also correct. Xavier 的解决方案有效, mklement0 的评论也是正确的。

Solution #1解决方案#1

Do what Xavier said (and upvote his answer).Xavier 所说的去做(并支持他的回答)。

But, if you don't want to mess up registry settings (or if, like me, you have lots of registry settings nestled under the HKCU\Console root), then...但是,如果您不想弄乱注册表设置(或者,如果像我一样,您在 HKCU\Console 根目录下有很多注册表设置),那么...

Solution #2解决方案#2

  1. Get Windows 10 build number 18309 (or newer)获取 Windows 10 内部版本号 18309(或更高版本)
    • Join the Windows Insider Program加入 Windows 预览体验计划
    • Make sure you're on a "ring" that includes a new-enough build.确保您处于包含足够新版本的“环”上。 For me at this moment that meant joining the "fast" ring对我来说,这意味着加入“快速”环
    • Wait forever for updates to finish installing永远等待更新完成安装
  2. Add "terminal.integrated.windowsEnableConpty": true to your settings.json"terminal.integrated.windowsEnableConpty": true添加到您的settings.json
  3. Restart terminals重启终端
  4. Upvote mklement0's comment支持mklement0 的评论
  5. ... ...
  6. Profit!利润!

On March 8th 2022 the default value for the integrated terminal "minimum contrast ratio" was updated from 1 (no effect) to 4.5 (minimal effect). 2022 年 3 月 8 日,集成终端“最小对比度”的默认值从 1(无效果)更新为 4.5(最小效果)。 Depending on your color settings and what is being displayed, this can cause your integrated terminal foreground colors to be wrong.根据您的颜色设置和显示的内容,这可能会导致您的集成终端前景色出现错误。

To disable this feature, override the default in your own settings.json file:要禁用此功能,请覆盖您自己的settings.json文件中的默认值:

  "terminal.integrated.minimumContrastRatio": 1

I am new to VS Code (and I'm trying to better my PowerShell skills) and have/had this same problem.我是 VS Code 的新手(我正在努力提高我的 PowerShell 技能)并且有/遇到过同样的问题。 Deleting all the Reg keys cited above related to colors seemed to fix it, but I believe the root problem is that VS Code seems to be trying to honor the color scheme set up outside the VS Code Terminal itself, from the shell.删除上面提到的所有与颜色相关的 Reg 键似乎可以解决它,但我认为根本问题是 VS Code 似乎试图从 shell 中尊重在 VS Code 终端本身之外设置的配色方案。 Really annoying and I'm not sure how to separate the two.真的很烦人,我不确定如何将两者分开。

I had setup a blue background/yellow font scheme in PS prior to installing VS Code.在安装 VS Code 之前,我在 PS 中设置了蓝色背景/黄色字体方案。 That was the same color scheme the terminal in VS Code was displaying directly around the text.这与 VS Code 中的终端直接在文本周围显示的配色方案相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM