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

Terminal Tmux-Tmux真彩色无法正常工作,terminal,tmux,Terminal,Tmux,我使用tmux已经有一段时间了 我使用vim进行编码,我注意到只有在将vim与tmux一起使用时,才存在一些与配色方案相关的缺陷 运行此命令时,两个终端都支持256色:tput colors 当我测试终端是否支持真彩色时,结果如下: curl -s https://raw.githubusercontent.com/JohnMorales/dotfiles/master/colors/24-bit-color.sh | bash 终端的输出如下所示: 但当我在tmux中运行此功能时: 我已

我使用tmux已经有一段时间了

我使用vim进行编码,我注意到只有在将vim与tmux一起使用时,才存在一些与配色方案相关的缺陷

运行此命令时,两个终端都支持256色:tput colors

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

curl -s https://raw.githubusercontent.com/JohnMorales/dotfiles/master/colors/24-bit-color.sh | bash
终端的输出如下所示:

但当我在tmux中运行此功能时:

我已经检查了echo$TERM的结果,但它们都返回以下内容:

xterm-256color
所以我真的很困惑这里可能有什么问题=\

有什么想法吗


非常感谢

也许您在设置时忽略了这一点(可以看出您忽略了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
-g
的对比,该公司表示:

设置选项
[-agoqsuw][t目标会话|目标窗口]选项值 (别名:set)
使用-w设置窗口选项(相当于 设置窗口选项命令),否则为带有
-s
的服务器选项 会话选项。如果给出了
-g
,则全局会话或窗口 选项已设置。u标志取消了一个选项的设置,因此会话 从全局选项继承选项(或使用-g, 将全局选项恢复为默认设置)

-o标志阻止设置已设置的选项,并且 -q标志抑制有关未知或不明确的错误 选项

使用
-a
,如果选项需要字符串或样式,则输入值 将附加到现有设置

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

进一步阅读:

  • (课程常见问题)

请您解释一下
set option-sa terminal overrides“,xterm*:Tc“
set option-ga terminal overrides”,xterm-256color:Tc“
(这似乎是大多数博客文章推荐的)到目前为止您推荐的代码片段
set option-sa terminal overrides”,xterm*:Tc“
是唯一对我有用的东西。
-sa
而不是
-ga
确实是让真彩色适合我的关键因素。非常感谢。以交互方式运行
set option
命令(即通过
,而不是通过将命令添加到tmux.conf),我发现它在我的tty中没有生效,直到我分离了tmux并重新连接。@OtisWright
-s
是一个服务器选项
-g
是一个全局会话选项(与只影响当前会话的非全局会话选项相比)。answer在解释它方面比我做得更好。现在(tmux 3,可能以前)使用
RGB
选项比使用
Tc
tmux扩展更可取。
# 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).