TERM xterm, xterm-color or xterm-256color: which to use
What the TERM values xterm, xterm-color and xterm-256color mean in terminfo, why xterm-color is an old choice, and which one to set for SSH, tmux and vim.
TERM names the terminfo entry that programs on the host use to know what your terminal can do. Three names come up again and again. They describe different terminals, and picking the wrong one gives you missing colors or a screen that does not clear properly.
What each name means
The entries come from the terminfo database shipped with ncurses:
xterm: "xterm terminal emulator". In current ncurses it is the same asxterm-new, a modern xterm with 8 colors, function keys, bracketed paste and back color erase.xterm-color: "generic color xterm". It is built on the old X11R6 xterm entry with 8 colors added. It does not list back color erase (bce).xterm-256color: "xterm with 256 colors". It is the modernxterm-newentry with the 256-color palette.
You can check what the host thinks with:
infocmp -1 xterm-256color | grep colors
tput colors
tput colors prints 8 for xterm and 256 for xterm-256color.
Why xterm-color is an old choice
The xterm FAQ calls xterm-color a bad choice for modern xterm, because the entry describes a terminal without back color erase. It still works with a modern xterm, but programs then clear the screen in a less efficient way. The name dates from when the plain xterm entry (X11R6 xterm) had no colors.
Which one to use
xterm-256colorfor nearly every modern terminal app, including over SSH. It is in the standard terminfo database that ncurses ships. vim, tmux and other programs then use 256 colors.xtermif a host does not havexterm-256color. You lose the 256-color palette, but keys and screen handling stay correct.vt100orvt220for very old systems or network devices that know nothing else.
True color (24-bit) is not described by any of these names; programs detect it in other ways. See Colors: 16, 256 and true color.
If the host says it does not know your terminal type, see TERM and terminfo.
Related
- TERM and terminfo
- VT, xterm and terminal types
- Colors: 16, 256 and true color
- Colors wrong in tmux: get 256 colors and true color (default-terminal, RGB)
- App guide: Colors in SSH, Mosh and Telnet sessions