!matthew

truecolor support using mosh and tmux

assess your baseline.

There are a variety of technologies at play and each one needs to work end-to-end. The core of the debugging is an awk script termstandard/colors which will emit a color test (see example output below).

script.

'BEGIN {
    s="/\\/\\/\\/\\/\\"; s=s s s s s s s s;
    for (colnum = 0; colnum<77; colnum++) {
        r = 255-(colnum*255/76);
        g = (colnum*510/76);
        b = (colnum*255/76);
        if (g>255) g = 510-g;
        printf "\033[48;2;%d;%d;%dm", r,g,b;
        printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
        printf "%s\033[0m", substr(s,colnum+1,1);
    }
printf "\n";
}'

example outputs.

correct output.

Screenshot of a bash terminal displaying a correct output of a color test script.

incorrect output.

Screenshot of a bash terminal displaying an incorrect output of a color test script.

Assert truecolor is working, using the above script, under:

  1. The local shell, under the terminal emulator of choice. An even longer line that will wrap.
  2. The remote shell, over SSH
  3. The remote shell, over mosh
  4. The remote shell, over mosh, inside of a tmux session
  5. If needed: the local shell, inside of tmux

If you encounter an incorrect output, debugging

final setup.

software.

configurations.

.tmux.conf

The only change required for tmux.

set-option -ga terminal-overrides ",xterm-256color:Tc"

.bashrc

More of an "unconfiguration," do not set $TERM in your bash shell.