3

So by mistake I deleted a bunch of my environment variables...
The one I cannot make sense of is TERM, a system-variable. Is this supposed to refer to the windows terminal? What value should I set it to?

5

That's fine. Regardless of the OS, TERM should never be defined system-wide.

In general, environment is a per-process thing. Both the "system" or "user" lists are only used to initialize the environment variables at login time, but afterwards the "current" environment is copied from parent process to child process, and each process could alter its own environment without affecting the rest of the system.

The purpose of TERM is to describe which terminal type is connected to the input/output of this specific process. TERM is meaningless for graphical programs (including even the terminals themselves), and can vary in value between terminals as they have different capabilities. For example, if you have Xterm and Urxvt running side-by-side, you will see "TERM=xterm" in one but "TERM=rxvt-unicode" in another.

Because of that, only the terminal app itself should set TERM for its child processes. (I'm not sure if that's possible with Conhost on Windows, due to it being a child of the console app rather than the parent.)


The Ncurses terminfo database has the ms-terminal TERM definition for the Windows Terminal app, although xterm or xterm-256color is "compatible enough" (it's what most apps understand, so it's what most new terminals try to emulate).

Similarly, MinTTY (the Cygwin Terminal) has the mintty terminfo file in Ncurses, but is also mostly xterm compatible. The Windows console (Conhost) would probably use ms-vt100+ or ms-vt100-color.

(That being said, apps running locally on the Windows Terminal will usually work without TERM, either because they already know they're running on Windows, or because they assume the entire world is xterm-compatible, or because they don't use terminal emulation in the first place (i.e. they use the old Windows "console" APIs). When you 'ssh' to another host, however, the SSH client should send a TERM value to be set on the server.)

1

TERM is widely used in unix-based systems, but it's not in use in Windows. You don't need to set it (my Windows 10, a pretty standard development machine, doesn't have it).

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.