mobile-shell / mobile-shell/mosh

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

Open
#1,333 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
14.5k
Forks
865
PR merge metrics
No merged PRs in 30d

Description

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:

https://github.com/mobile-shell/mosh/blob/1105d481bb9143dad43adf768f58da7b029fd39c/src/frontend/mosh-server.cc#L572-L578

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/frontend/mosh-server.cc lines 572-578 and compare its terminfo color-count handling with the truecolor example using tput -T alacritty-direct colors. Done means terminals advertising truecolor no longer fall back to TERM=xterm, while existing 256-color behavior remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.