如何使Alacritty显示真颜色

发布于 2025-01-27 18:32:47 字数 2070 浏览 2 评论 0 原文

由于某种原因,我的Alacritty安装没有使用配置文件中指定的颜色。

这是我的配置的相关部分。

env:
  TERM: alacritty

colors:
  primary:
    background: '#1c1f26'
    foreground: '#d8dee9'
    dim_foreground: '#a5abb6'
    cursor:
      text: '#2e3440'
      cursor: '#d8dee9'
    vi_mode_cursor:
      text: '#2e3440'
      cursor: '#d8dee9'
    selection:
      text: CellForeground
      background: '#4c566a'
    search:
      matches:
        foreground: CellBackground
        background: '#88c0d0'
      bar:
        background: '#434c5e'
        foreground: '#d8dee9'
    normal:
      black: '#3b4252'
      red: '#bf616a'
      green: '#a3be8c'
      yellow: '#ebcb8b'
      blue: '#81a1c1'
      magenta: '#b48ead'
      cyan: '#88c0d0'
      white: '#e5e9f0'
    bright:
      black: '#4c566a'
      red: '#bf616a'
      green: '#a3be8c'
      yellow: '#ebcb8b'
      blue: '#81a1c1'
      magenta: '#b48ead'
      cyan: '#8fbcbb'
      white: '#eceff4'
    dim:
      black: '#373e4d'
      red: '#94545d'
      green: '#809575'
      yellow: '#b29e75'
      blue: '#68809a'
      magenta: '#8c738c'
      cyan: '#6d96a5'
      white: '#aeb3bb'

颜色部分几乎完全来自Nord配色方案,除了我使我变暗的背景颜色。

但是,当我测试用于16个基本颜色(使用逃生)序列的颜色时:

printf "\033[0;32m_hello_\033[0m\n"    #to display "_hello_" in the color green

我得到的颜色在我的任何配置中都不存在,

我试图确定使用<< a href =“ https://aur.archlinux.org/packages/colorpicker” rel =“ nofollow noreferrer”> colorpicker aur aur so:so:

colorpicker --short --one-shot --preview

显示的颜色与显示的颜色完全不同在配置中指定的。例如:

  • 对于绿色而不是#a3be8c ,我获得#b5bd68
  • 对于红色而不是#bf616a ,我得到#cc66666 < /code>

据我所知,预期和实际颜色之间没有明确的关系。我不确定,也许有一些颜色近似。

我在这里做错了什么?如果这是一个近似问题,我该如何使Alacritty使用TrueColor?


编辑:Chaging 术语 to xterm-256Color 无法解决问题

For some reason, my alacritty install is not using the colors specified in the config file.

Here is the relevan section of my config.

env:
  TERM: alacritty

colors:
  primary:
    background: '#1c1f26'
    foreground: '#d8dee9'
    dim_foreground: '#a5abb6'
    cursor:
      text: '#2e3440'
      cursor: '#d8dee9'
    vi_mode_cursor:
      text: '#2e3440'
      cursor: '#d8dee9'
    selection:
      text: CellForeground
      background: '#4c566a'
    search:
      matches:
        foreground: CellBackground
        background: '#88c0d0'
      bar:
        background: '#434c5e'
        foreground: '#d8dee9'
    normal:
      black: '#3b4252'
      red: '#bf616a'
      green: '#a3be8c'
      yellow: '#ebcb8b'
      blue: '#81a1c1'
      magenta: '#b48ead'
      cyan: '#88c0d0'
      white: '#e5e9f0'
    bright:
      black: '#4c566a'
      red: '#bf616a'
      green: '#a3be8c'
      yellow: '#ebcb8b'
      blue: '#81a1c1'
      magenta: '#b48ead'
      cyan: '#8fbcbb'
      white: '#eceff4'
    dim:
      black: '#373e4d'
      red: '#94545d'
      green: '#809575'
      yellow: '#b29e75'
      blue: '#68809a'
      magenta: '#8c738c'
      cyan: '#6d96a5'
      white: '#aeb3bb'

The colors section is pretty much taken exactly from nord color scheme, except for the background color which I have made a bit darker.

However, when I test the color used for the 16 base colors (using the escape) sequences like so:

printf "\033[0;32m_hello_\033[0m\n"    #to display "_hello_" in the color green

I get a color that is not present anywhere in any config of mine

I'm trying to determine the actual color displayed by using the colorpickerAUR package like so:

colorpicker --short --one-shot --preview

The displayed colors are completely different from the ones specified in the config. For example:

  • For green instead of #a3be8c, I get #b5bd68
  • For red instead of #bf616a, I get #cc6666

As far as I can tell there is no clear relationship between the expected and actual colors. Maybe there is some color approximation going on, I'm not sure.

What am I doing wrong here? If this is an approximation issue, how do I make alacritty use truecolor?


Edit: Chaging TERM to xterm-256color doesn't fix the problem

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

戏剧牡丹亭 2025-02-03 18:32:47

最近,我偶然发现了同样的问题。我正在开发一个TMUX主题,在增加对16位颜色的支持时,我注意到颜色表示实际上并不准确地适合原始值。

我找到了在此页面 @andersevenrud上,我可以在@andersevenrud上提供更多详细的解释,从而帮助我提供了

解决方案

在Macos Sonoma 14.6.1上测试,Alacritty 0.13.2,Tmux 3.4

# ~/.config/alacritty/alacritty.toml
[env]
TERM = "xterm-256color"
  • 测试。
# ~/.tmux.conf
set -g default-terminal "tmux-256color"
set -ag terminal-overrides ",xterm-256color:RGB"  # <- this did a trick for me

进行了 如果这对您没有帮助,我鼓励您访问@andersevenrud 发现替代配置。

Recently, I stumbled upon the same problem. I was developing a tmux theme, and while adding support for 16-bit colors, I noticed the color representation was not actually accurate to the original values.

I found the solution that helped me on this page where @andersevenrud provides a more detailed explanation with other commenters who also post alternative configurations.

Solution

Tested on macOS Sonoma 14.6.1, alacritty 0.13.2, tmux 3.4

  • in alacritty config
# ~/.config/alacritty/alacritty.toml
[env]
TERM = "xterm-256color"
  • in tmux config
# ~/.tmux.conf
set -g default-terminal "tmux-256color"
set -ag terminal-overrides ",xterm-256color:RGB"  # <- this did a trick for me

This was enough to finally get a correct representation of the colors. If this does not help you, I would encourage you to visit @andersevenrud guide for True Color (24-bit) to discover alternative configs.

何其悲哀 2025-02-03 18:32:47

我认为问题是您的缩进:您有 normal / bright / dim dim 过去 primary ,但是这些需要与 primary 处于相同的凹痕级别。

I think the problem is your indentation: You have normal/bright/dim indented past primary, but those need to be at the same indentation level as primary.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文