9

Originally, I was trying to determine why some directories show up differently colored than others when using the ls command.

While playing around with this. I have now encountered the problem of not being able to clear the screen inside a tmux terminal

$ clear
'tmux-256color': unknown terminal type.

This problem only persists in tmux, not the actual terminal itself and only showed up after trying to fix the initial problem. Also the colors have changed when running vim inside tmux now.

Here are some outputs:

outside tmux:

$ echo $TERM; tput colors; tput longname
xterm-256color
256
xterm with 256 colors

inside tmux:

echo $TERM; tput colors; tput longname
tmux-256color
tput: unknown terminal "tmux-256color"
tput: unknown terminal "tmux-256color"

EDIT:

my .bashrc file has:

case "$TERM" in
    xterm-color|*-256color) color_prompt=yes;;
esac

my .tmux.conf has:

set -g default-terminal "screen-256color"
1
  • You haven't told the world whether the tmux terminal type is missing, too.
    – JdeBP
    Mar 24, 2020 at 18:44

3 Answers 3

21

Your plaform doesn't have tmux-256color, you will need to either:

1) Use screen-256color instead.

2) See if you can upgrade ncurses or terminfo to a later version with tmux-256color.

3) Copy tmux-256color from another computer which does have it, you can do this by saving it with infocmp -x tmux-256color >saved then installing it with tic -x saved.

4
  • 1
    How do I persistently change it to your first point? I think i've done it before with export $TERM=screen-256color but after closing the terminal and restarting, the same error occured. Mar 24, 2020 at 17:47
  • The better approach is to leave it at the right terminal type, as it currently is, and use M. Marriott's second or third options.
    – JdeBP
    Mar 24, 2020 at 18:42
  • 1
    Yeah, that's worked for me. point 3 is persistence. @DouglasJamesBock please vote this answer as solution.
    – silvio
    May 26, 2020 at 5:53
  • Regarding the export command of @DouglasJamesBock : there's no $-sign while setting variables; the $ is only used to show the content, e.g. echo $TERM
    – Gerd
    Nov 9, 2023 at 7:12
9

An approach that has always worked for me in this situation (when ssh'ing onto a foreign VM etc) is simply typing

export TERM=xterm

You can also add this as a .profile entry on the foreign box too if permission allows to make it permanent.

-2

By default tmux used TERM=screen256 on Ubuntu for color display. However I could not display icon etc. in tmux.

By using export LANG=en_IN.utf-8 it solved the problem. Another approach I used to display correctly was by using tmux -u.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .