Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
johntyree opened this issue Dec 27, 2024 · 1 comment
Open

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

johntyree opened this issue Dec 27, 2024 · 1 comment

Comments

@johntyree
Copy link

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 :(.

@johntyree
Copy link
Author

Since there seems to be an unspoken convention of reporting 256 colors even when you support more than 256 colors, perhaps the best thing to do is simply colors >= 256 instead of colors == 256.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant