0

I have a bunch of dotfiles that allow me to have a pretty theme on my terminal and tmux on my local host. I use kitty, fish and tmux. To properly define colors and have a global coherence, I use the following files :

  • .Xresoures
  • kitty.conf
  • fish_prompt.fish
  • .tmux.conf

On my local host, everything looks really clean : enter image description here

I also have a remote server, which runs the same arch + fish + tmux and uses exactly the same dotfiles. However, when SSH-ing into the server, everything looks completely different :

enter image description here

I have google around and there are a lot of tutorials that tell you to add a bunch of weird configs, but none actually explain what is really happening under the hood (also, as you can see, none of them worked).

Here is what I tried to do to make it work (without really understanding why) :

  • Added to tmux.conf :
set^[[3m -g default-terminal "xterm-kitty"
set-option^[[3m -ga terminal-overrides ",xterm-kitty*:Tc"
  • Added the xterm-kitty terminfo file
  • Change the TERM env variable to xterm-kitty on login

I would love for some resources to point to how this all works! Thanks!

Edit :

For clarity, here are the values of TERM I have :

  • On local host : xterm-kitty
  • On local host inside tmux : xterm-256color
  • On remote host directly after opening ssh : xterm-kitty
  • On remote host in tmux : xterm-256color

All files are synced using a git repo, all versions are identical. I have transfered the same terminfo file related to xterm-kitty on both hosts. Also, using this script, I can see that all colors are properly displayed and identical on both hosts.

I also noticed that logging into the remote machine without tmux yields yet another combination of colors (same fish config file used everywhere) :

enter image description here

3

default-terminal sets the default TERM inside tmux. Do not set this to xterm-kitty - tmux is not xterm, or kitty. Set it to tmux-256color if it exists on your computer (check infocmp tmux-256color), otherwise screen-256color.

Similarly, do not set TERM in shell profiles to the same thing for all terminals.

The terminal-overrides line you have tells tmux that when it sees TERM set to xterm-kitty it means the terminal supports true (RGB) colour (hence Tc).

TERM inside tmux tells programs inside tmux what they are talking to (tmux). TERM outside tmux tells tmux what it is talking to (in this case, kitty).

If it works locally but not over ssh then the most likely things are:

  • Different TERM outside tmux. Are you sure echo $TERM shows the same immediately before you start tmux on both your local computer and over ssh?

  • The tmux configs are not actually the same, are you sure they are? If you need terminal-overrides in one place you will need it in the other, if not then you won't.

  • Are you sure xterm-kitty exists on both computers and is the same? Check infocmp xterm-kitty.

  • Different tmux versions. Are you sure they are the same? Check tmux -V.

5
  • Thanks for your reply, I have added a bunch of clarifications to the question to cover for your questions. I do understand the problem a little better now, thanks! – alpha1554 Apr 10 '20 at 12:47
  • 1
    If it is different without tmux, I would focus on that first - the only things at fault in that case could be kitty, fish or the xterm-kitty terminfo file you have installed. Is it also different if you use another terminal like xterm or gnome-terminal? Are you sure there is no default fish config that is interfering? – Nicholas Marriott Apr 10 '20 at 13:04
  • Using xterm locally without tmux yields results that are identical to using tmux on the remote SSH host. I'll continue messing with different settings to see if I can make it work. Thanks! – alpha1554 Apr 10 '20 at 13:55
  • There is no xterm-kitty in vanilla terminfo. The correct rendered-upon terminal type is, assuming that this is KiTTY rather than kitty, probably putty-256color. – JdeBP Apr 10 '20 at 14:33
  • No, this is about kitty the terminal emulator. This one has its own terminfo. – alpha1554 Apr 10 '20 at 14:47
3

If you're using tmux on the local-machine, then running ssh to the remote machine, there's no way that the remote session can tell that you're able to use RGB colors instead-of (or in addition to) indexed (256-colors). That's because the tmux "Tc" override is not visible to the remote session.

You can work around this by modifying the terminal description which corresponds to the default-terminal setting of tmux, e.g., by adding whatever settings you use with terminal-overrides to the text-file for the terminal description, and using tic to compile it (on each machine). For example (if the default-terminal is tmux):

infocmp -x tmux >foo
printf '\tTc,\n' >>foo
tic -x foo

Kitty has an FAQ, but it overlooks "-x" for infocmp.

There are a couple of remaining points to consider:

  • Copying the binary files created by tic is unreliable (for more than one reason).

  • If the same terminal description is available on the remote side, you'll get (more) consistent behavior, assuming that the remote application uses the terminal description content rather than the name of the terminal description.

0

Managed to fix it! It was a combination of all the answers given, with one important extra variable.

Required steps :

infocmp -x tmux-256color >foo
printf '\tTc,\n' >>foo
tic -x foo
  • Add set -g fish_term24bit 1 to my config.fish in order to force fish to use trucolor mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.