How can I find the valid values for TERM to use in tmux?

7,377

Solution 1

The toe command will show you the terminfo definitions on the current system. If you lack that command, you see the raw data in /usr/share/terminfo on most Linux systems.

Solution 2

The toe program lists entries in the ncurses terminal database, but its may not be useful in a simple menu.

For instance, Debian's ncurses-base package lists someone's notion of the most common terminal descriptions:

This package contains terminfo data files to support the most common types of terminal, including ansi, dumb, linux, rxvt, screen, sun, vt100, vt102, vt220, vt52, and xterm.

The selection is ad hoc, and reflects bug reports. Checking the actual package;

ansi cons25 cons25-debian cygwin dumb Eterm Eterm-color hurd linux mach mach-bold mach-color mach-gnu mach-gnu-color pcansi rxvt rxvt-basic rxvt-m rxvt-unicode screen screen-256color screen-256color-bce screen-bce screen-s screen-w sun vt100 vt102 vt220 vt52 wsvt25 wsvt25m xterm xterm-256color xterm-color xterm-debian xterm-mono xterm-r5 xterm-r6 xterm-vt220 xterm-xfree86

or 41 entries. Looking at the list, there are several places to disagree:

  • xterm-xfree86 was deprecated in favor of xterm-new 12 years ago.
  • users for hurd (and the related mach entries) are few, and
  • it includes none of the corrected entries for konsole or vte. To get those (as well as the corrected 256color variants), you would need ncurses-term (which has 2675 entries).

The infocmp program is not ncurses-specific, so you would be able to use that on more platforms — to check for existence. But if you want to check for existence (and look at specific capabilities), tput is the place to start.

On most of the systems you are likely to use, you would be using ncurses terminal database — or some packager-defined subset. Since the ncurses terminal database defines the 256color variants by appending the "-256color" to the recommended name for the terminal, the way you would find a suitable one is by simply testing for the existence of the preferred name with the suffix.

Further reading:

Share:
7,377

Related videos on Youtube

0xC0000022L
Author by

0xC0000022L

human father bibliophile geek & ~nerd misanthropic philanthropist skeptic code necromancer programmer reverse engineer (RCE) / software archaeologist / grayhat hacker moderator on reverseengineering system administrator FLOSS enthusiast Debian, FreeBSD and Ubuntu aficionado

Updated on September 18, 2022

Comments

  • 0xC0000022L
    0xC0000022L 2 months

    When starting tmux I need to pass a valid terminal type. Since I am scripting the initial startup of tmux I would like to cover all bases by figuring out the valid values of TERM on the current system.

    How do I find valid values to use for tmux and which order, including a possible 16 color fallback, should I prefer?

    This is mainly for Linux systems, but I presume the approach would be similar on most other unixoids.

    • Ignacio Vazquez-Abrams
      Ignacio Vazquez-Abrams almost 10 years
      Why isn't your terminal setting one already?
    • 0xC0000022L
      0xC0000022L almost 10 years
      It is, but that's not compatible with the way I want/need to run tmux. In order to force it to use 256 colors, I need to explicitly set it on the server I am connecting to.
    • Incnis Mrsi
      Incnis Mrsi about 7 years
  • 0xC0000022L
    0xC0000022L almost 10 years
    Great, thanks. toe -a|awk '{print $1}' is the kind of list I have been looking for. +1 and accept :)
  • Admin
    Admin almost 10 years
    Nice! Didn't know of toe until now.
  • Walf
    Walf over 6 years
    toe -a | sort | less