7

I recently switched from rxvt-unicode to st. This means I went from $TERM=rxvt-unicode-256color to $TERM=st-256color.

I'm happy with the switch and want to continue to use st. However, I've noticed that certain terminal applications are unhappy with the new $TERM value. For example, emacs will not load in st with full color support unless I "trick" it into thinking that $TERM is something recognizable like $TERM=xterm-256color.

My question is: what's the risk of simply setting $TERM=xterm-256color? It seems to me that the important part of $TERM=*-256color is the 256color part and the value of * seems less important.

1 Answers1

15

The important part of the value of TERM is that it matches an entry in the terminfo or termcap databases, and that that entry correctly describes your terminal.

You cannot reasonably go telling softwares that your terminal is XTerm, when it blatantly is not. And it is an outright error to think that other terminal emulators use all the same input/output control sequences as XTerm or provide all the same functionality.

-256color is simply a part of a name, it has no inherent meaning to most softwares (albeit that a very few do look for feature suffixes). It (primarily) only has meaning to human beings, as it is human beings that group the entries in the terminfo/termcap databases into families by their names. The feature suffixes in terminal type names are primary for humans, not for softwares.

The thing that has meaning to softwares is whether the record in the database that is so named says that the terminal supports 256 colours, and provides the control sequences for using them on that type of terminal.

That said, emacs does do its own thing, and does not simply rely upon the terminfo/termcap database. For example, it is known that its frame-set-background-mode function matches the value of TERM against ^\\(xterm\\|\\rxvt\\|dtterm\\|eterm\\), which is probably wrong nowadays. The correct approach here is to fix emacs so that, at last, it properly recognizes the st-256color terminal type (and putty-256color, vte-256color, and others).

Further reading

JdeBP
  • 68,745
  • Thanks for the info. I fixed my emacs problem by adding (add-to-list 'term-file-aliases '("st-256color" . "xterm-256color")). However, this is killing my emacs startup time so I was curious if taking a sledgehammer to the problem would cause issues... and it sounds like it probably would! – Brian Fitzpatrick Apr 25 '19 at 18:13
  • I'm new to the idea of terminfo, so how can I setup this file? – Niing Apr 12 '21 at 05:12