gpt4 book ai didi

terminal - Tmux - Tmux 真彩色无法正常工作

转载 作者:行者123 更新时间:2023-12-02 20:45:54 25 4
gpt4 key购买 nike

我现在使用 tmux 一段时间了,

我使用 vim 进行编码,并且仅当我将 vim 与 tmux 一起使用时,我才注意到一些与颜色方案相关的缺陷。

当我运行以下命令时,两个终端都支持 256 色:tput color

当我测试我的终端以查看是否支持真彩色时,结果如下:

curl -s https://raw.githubusercontent.com/JohnMorales/dotfiles/master/colors/24-bit-color.sh | bash

终端的输出是这样的: enter image description here

但是当我在 tmux 中运行它时: enter image description here

我已经检查了 echo $TERM 的结果,但它们都返回了这个:

xterm-256color

所以我真的很困惑这里可能存在什么问题=\

有什么想法吗?

非常感谢!

最佳答案

也许您在设置时忽略了这一点(可以看出您忽略了Tc):

commit 427b8204268af5548d09b830e101c59daa095df9
Author: nicm <nicm>
Date: Fri Jan 29 11:13:56 2016 +0000

Support for RGB colour, using the extended cell mechanism to avoid
wasting unnecessary space. The 'Tc' flag must be set in the external
TERM entry (using terminal-overrides or a custom terminfo entry), if not
tmux will map to the closest of the 256 or 16 colour palettes.

Mostly from Suraj N Kurapati, based on a diff originally by someone else.

在 tmux.conf 中:

# Enable RGB colour if running in xterm(1)
set-option -sa terminal-overrides ",xterm*:Tc"

在联机帮助页中:

TERMINFO EXTENSIONS
tmux understands some unofficial extensions to terminfo(5):
...
Tc Indicate that the terminal supports the ‘direct colour’ RGB
escape sequence (for example, \e[38;2;255;255;255m).

If supported, this is used for the OSC initialize colour escape
sequence (which may be enabled by adding the ‘initc’ and ‘ccc’
capabilities to the tmux terminfo(5) entry).

关于 -s-gmanual page说:

set-option [-agoqsuw] [-t target-session | target-window] option value (alias: set)
Set a window option with -w (equivalent to the set-window-option command), a server option with -s, otherwise a session option. If -g is given, the global session or window option is set. The -u flag unsets an option, so a session inherits the option from the global options (or with -g, restores a global option to the default).

The -o flag prevents setting an option that is already set and the -q flag suppresses errors about unknown or ambiguous options.

With -a, and if the option expects a string or a style, value is appended to the existing setting.

据我了解,使用 -s 意味着新连接(由服务器创建)将获得此设置,这在 shell 初始化中很有用,而 -g 对其更改对于 shell 来说太晚了初始化。

进一步阅读:

关于terminal - Tmux - Tmux 真彩色无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41783367/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com