How important is it that $TERM is correct?

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.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x