1

Why does tmux report

$TERM=screen-256color

Normally kitty reports

$TERM=xterm-kitty

Which should I use if I run tmux inside kitty? Obviously kitty provides advanced functionality and that makes sense that it reports xterm-kitty. Why does screen report that it's screen-256 are there programs that need to be aware that they're running in screen? Would it be problematic to call screen running in kitty xterm-kitty?

1

Which should I use if I run tmux inside kitty?

When running tmux then you must use TERM=screen, TERM=tmux, or one of the derivatives e.g. TERM=screen-256color or TERM=tmux-256color.

man tmux(1) states ...

The TERM environment variable must be set to “screen” for all programs running inside tmux. New windows will automatically have “TERM=screen” added to their environment, but care must be taken not to reset this in shell start-up files.

.. and further down clarifies ...

Set the default terminal for new windows created in this session - the default value of the TERM environment variable. For tmux to work correctly, this must be set to ‘screen’ or a derivative of it.

... they also emphasize must.

The tmux wiki continues with additional clarification and answers ...

Inside tmux TERM must be "screen", "tmux" or similar (such as "tmux-256color"). Don't bother reporting problems where it isn't!

Are there programs that need to be aware that they're running in screen?

Yes. Many programs, such as tput, will not display correctly when they're running in screen (or tmux) unless they're using the correct TERM value.

What is TERM and what does it do?

The environment variable TERM tells applications the name of a terminal description to read from the terminfo(5) database. Each description consists of a number of named capabilities which tell applications what to send to control the terminal. For example, the "cup" capability contains the escape sequence used to move the cursor up.

It is important that TERM points to the correct description for the terminal an application is running in - if it doesn't, applications may misbehave.

The infocmp(1) command shows the contents of a terminal description and the tic(1) command builds and installs a description from a file (the -x flag is normally required with both).

Would it be problematic to call screen running in kitty xterm-kitty?

Not necessarily, as long as the TERM value in the running screen is set correctly (i.e. TERM=screen-256color) and there's valid terminfo strings for it that screen or tmux knows how to handle.

Other derivatives (on my machine) are:

/usr/share/terminfo/s/screen
/usr/share/terminfo/s/screen-16color
/usr/share/terminfo/s/screen-256color
/usr/share/terminfo/s/screen.Eterm
/usr/share/terminfo/s/screen.gnome
/usr/share/terminfo/s/screen.konsole
/usr/share/terminfo/s/screen.linux
/usr/share/terminfo/s/screen.mlterm
/usr/share/terminfo/s/screen.mrxvt
/usr/share/terminfo/s/screen.rxvt
/usr/share/terminfo/s/screen.teraterm
/usr/share/terminfo/s/screen.vte
/usr/share/terminfo/s/screen.xterm-r6
/usr/share/terminfo/s/screen.xterm-new
/usr/share/terminfo/s/screen.xterm-xfree86

Once TERM is set, you could run infocmp. That will report if there's a valid terminfo for the value. Other tests can validate basic terminfo functionality, such as:

for terminfos in $(find /usr/share/terminfo/s -type f -name 'screen*' -printf '%f\n' -o -name 'tmux*' -printf '%f\n'); do export TERM=$terminfos; printf "%s: %sthis is foreground color 10 %sitalics%s and now all attributes are turned off\n" "$terminfos" "$(tput setaf 10)" "$(tput sitm)" "$(tput sgr0)"; done

  • That last answer from superuser is less than useful. screen's emulating something that's a particular terminal type more/less for consistency. tmux uses the same terminal description to (try to) not rely upon a new terminal description being installed. Ultimately that doesn't work well, but for reasons outside the scope of this question. – Thomas Dickey Nov 28 '18 at 22:55
0

Kitty's advanced functionality isn't compatible with things like tmux. For example if you run tmux and then run

$ kitty icat ~/Pictures/fc.jpg 
Terminal does not support reporting screen sizes via the TIOCGWINSZ ioctl
$ TERM=xterm-kitty kitty icat ~/Pictures/fc.jpg 
Terminal does not support reporting screen sizes via the TIOCGWINSZ ioctl

So you can see even if you fudge TERM under tmux to match the one Kitty reports, you'll find a dead end, at best. Under ranger, range just crashes when trying to render a preview.

  • I'm a bit confused why the answer addresses tmux when the bulk of the question focuses on screen? – Jeff Schaller Nov 28 '18 at 22:39
  • If kitty doesn't support the ioctl, that's a bug. But it's unrelated to the TERM value. – Thomas Dickey Nov 28 '18 at 22:57
  • @JeffSchaller the question is 100% about tmux, tmux just reports its term is screen. But, I did have one typo =) – Evan Carroll Nov 29 '18 at 0:24
0

That's several questions. Here are answers for the more interesting ones:

  • Why does tmux report

    $TERM=screen-256color

Older releases of tmux use TERM=screen or TERM=screen-256color "because it's there". Ultimately that changed (a) because tmux's developer wanted to add features and (b) because screen interferes with using italics.

  • Normally kitty reports

    $TERM=xterm-kitty

    Which should I use if I run tmux inside kitty?

You should let tmux choose (it looks at the outer terminal description to see how to handle color and function-keys).

  • Why does screen report that it's screen-256

Probably meant to say "screen-256color". GNU screen looks at the outer $TERM value and chooses an inner one. But this particular one comes from the user's .screenrc file (normally - packagers may get involved).

  • are there programs that need to be aware that they're running in screen?

Not really...

  • Would it be problematic to call screen running in kitty xterm-kitty?

Some screen configurations use bce (back color erase) by default. kitty doesn't support the feature (ymmv).

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.