Search code examples
terminaltmux

Tmux - Tmux true color is not working properly


I'm using tmux for sometime now,

I use vim for coding, and I've noticed some flaws related to the colorschemes ONLY when I'm using vim with tmux.

Both terminal support 256 colors when I run this: tput colors

When I test my terminal to see if support true colors this is the result:

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

the output from the terminal is this: enter image description here

but when I run this within tmux: enter image description here

I've checked the result of echo $TERM but both of them return this:

xterm-256color

So I'm really confused about what might be the problem here =\

Any idea?

Thanks a lot!


Solution

  • Perhaps you overlooked this in setting up (one can see that you overlooked 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.
    

    in tmux.conf:

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

    in the manpage:

    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).
    

    Regarding -s versus -g, the manual page says:

    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.

    As I understand it, Using -s means that new connections (created by the server) will get this setting, which is useful in shell initialization, while -g makes its changes too late for the shell initialization.

    Further reading: