Skip to content

Use TERM=xterm-256color (or better) when truecolor is supported. #1333

@johntyree

Description

@johntyree

The current situation is that mosh will manually test for color support using terminfo, which makes sense, but then it only checks to see if the value is 256 or not. If it's 256, it sets xterm-256color and if not, it sets xterm:

const char default_term[] = "xterm";
const char color_term[] = "xterm-256color";
if ( setenv( "TERM", ( colors == 256 ) ? color_term : default_term, true ) < 0 ) {
perror( "setenv" );
exit( 1 );
}

This is a problem when terminals support truecolor and correctly advertise that they support 16M colors via terminfo, e.g.

$ tput -T alacritty-direct colors
16777216

In this scenario, mosh says, "Well.. it's not 256 so I guess it's 8," and then sets TERM=xterm. Then everything that is run inside the session, including tmux, thinks that not even 256 colors are supported, let alone 16M colors. It would be great if COLORTERM=truecolor were sufficient, but unfortunately it's not. There are too many applications that only look at $TERM (via terminfo) and are thus broken :(.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions