What uses the TERM variable?Colors in Man PagesHow do keyboard input and text output work?Which terminal type am I using?What protocol/standard is used by terminals?How does a program decide whether or not to have coloured output?Difference between the terminal file and the terminal screenWhat's the difference between various $TERM variables?emacs colors based on $TERM environment variableEmacs Key-binding and the TERM variableWhat's the right value of $TERM for emacs' ansi-term, especially if 'eterm-color' isn't available after SSH?Is it correct to set the $TERM variable manually?Modular $TERM for different terminal emulatorsterm definitions not foundWhere does the TERM environment variable default get set?Why does tmux set TERM variable to screen?

Professor falsely accusing me of cheating in a class he does not teach, two months after end of the class. What precautions should I take?

I quit, and boss offered me 3 month "grace period" where I could still come back

Referring to different instances of the same character in time travel

During copyediting, journal disagrees about spelling of paper's main topic

How do I take a fraction to a negative power?

<schwitz>, <zwinker> etc. Does German always use 2nd Person Singular Imperative verbs for emoticons? If so, why?

Why would guns not work in the dungeon?

If a specific mass of air is polluted, will the pollution stick with it?

I have a ruthless DM and I'm considering leaving the party. What are my options to minimize the negative impact to the rest of the group?

'rm' (delete) thousands of files selectively

Did any of the founding fathers anticipate Lysander Spooner's criticism of the constitution?

Password maker in c#

Robbers: The Hidden OEIS Substring

Does Google Maps take into account hills/inclines for route times?

Why does resistance reduce when a conductive fabric is stretched?

Is this floating-point optimization allowed?

Why is dry soil hydrophobic? Bad gardener paradox

How can I deal with a player trying to insert real-world mythology into my homebrew setting?

How did the hit man miss?

Why isn't there research to build a standard lunar, or Martian mobility platform?

QGIS Welcome page: What is 'pin to list' for?

What is the difference between logical consistency and logical entailment in deductive logic?

Science writing - exact, precise, or accurate

Is Prophet from Facebook any different from a linear regression?



What uses the TERM variable?


Colors in Man PagesHow do keyboard input and text output work?Which terminal type am I using?What protocol/standard is used by terminals?How does a program decide whether or not to have coloured output?Difference between the terminal file and the terminal screenWhat's the difference between various $TERM variables?emacs colors based on $TERM environment variableEmacs Key-binding and the TERM variableWhat's the right value of $TERM for emacs' ansi-term, especially if 'eterm-color' isn't available after SSH?Is it correct to set the $TERM variable manually?Modular $TERM for different terminal emulatorsterm definitions not foundWhere does the TERM environment variable default get set?Why does tmux set TERM variable to screen?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








4















According to this document:




The environment variable TERM contains a identifier for the text
window’s capabilities. You can get a detailed list of these
cababilities by using the ‘infocmp’ command, using ‘man 5 terminfo’ as
a reference.




But how is the TERM variable actually used? Say, the system runs xterm (terminal emulator for the X Window System). Does xterm use the TERM variable, or is it the shell? If so, how? Would xterm stop working, if TERM is set to linux?



Also, why isn't colored output disabled if I change TERM from its default value of xterm-256color to something else like xterm?










share|improve this question
























  • These questions are way too broad, and an answer will turn into a treatise, but for the last of them it's simple: GNU ls and grep do NOT care about the TERM variable, they simply assume that any terminal supports ANSI color escapes.

    – Uncle Billy
    Jul 4 at 7:24






  • 1





    You can use this occasion to submit a doc patch to gettext to fix the spelling of "cababilities" in that manual.

    – Uncle Billy
    Jul 4 at 7:53

















4















According to this document:




The environment variable TERM contains a identifier for the text
window’s capabilities. You can get a detailed list of these
cababilities by using the ‘infocmp’ command, using ‘man 5 terminfo’ as
a reference.




But how is the TERM variable actually used? Say, the system runs xterm (terminal emulator for the X Window System). Does xterm use the TERM variable, or is it the shell? If so, how? Would xterm stop working, if TERM is set to linux?



Also, why isn't colored output disabled if I change TERM from its default value of xterm-256color to something else like xterm?










share|improve this question
























  • These questions are way too broad, and an answer will turn into a treatise, but for the last of them it's simple: GNU ls and grep do NOT care about the TERM variable, they simply assume that any terminal supports ANSI color escapes.

    – Uncle Billy
    Jul 4 at 7:24






  • 1





    You can use this occasion to submit a doc patch to gettext to fix the spelling of "cababilities" in that manual.

    – Uncle Billy
    Jul 4 at 7:53













4












4








4








According to this document:




The environment variable TERM contains a identifier for the text
window’s capabilities. You can get a detailed list of these
cababilities by using the ‘infocmp’ command, using ‘man 5 terminfo’ as
a reference.




But how is the TERM variable actually used? Say, the system runs xterm (terminal emulator for the X Window System). Does xterm use the TERM variable, or is it the shell? If so, how? Would xterm stop working, if TERM is set to linux?



Also, why isn't colored output disabled if I change TERM from its default value of xterm-256color to something else like xterm?










share|improve this question
















According to this document:




The environment variable TERM contains a identifier for the text
window’s capabilities. You can get a detailed list of these
cababilities by using the ‘infocmp’ command, using ‘man 5 terminfo’ as
a reference.




But how is the TERM variable actually used? Say, the system runs xterm (terminal emulator for the X Window System). Does xterm use the TERM variable, or is it the shell? If so, how? Would xterm stop working, if TERM is set to linux?



Also, why isn't colored output disabled if I change TERM from its default value of xterm-256color to something else like xterm?







terminal xterm






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 4 at 17:12









mosvy

14.9k2 gold badges18 silver badges49 bronze badges




14.9k2 gold badges18 silver badges49 bronze badges










asked Jul 4 at 7:00









ShuzhengShuzheng

2091 silver badge8 bronze badges




2091 silver badge8 bronze badges












  • These questions are way too broad, and an answer will turn into a treatise, but for the last of them it's simple: GNU ls and grep do NOT care about the TERM variable, they simply assume that any terminal supports ANSI color escapes.

    – Uncle Billy
    Jul 4 at 7:24






  • 1





    You can use this occasion to submit a doc patch to gettext to fix the spelling of "cababilities" in that manual.

    – Uncle Billy
    Jul 4 at 7:53

















  • These questions are way too broad, and an answer will turn into a treatise, but for the last of them it's simple: GNU ls and grep do NOT care about the TERM variable, they simply assume that any terminal supports ANSI color escapes.

    – Uncle Billy
    Jul 4 at 7:24






  • 1





    You can use this occasion to submit a doc patch to gettext to fix the spelling of "cababilities" in that manual.

    – Uncle Billy
    Jul 4 at 7:53
















These questions are way too broad, and an answer will turn into a treatise, but for the last of them it's simple: GNU ls and grep do NOT care about the TERM variable, they simply assume that any terminal supports ANSI color escapes.

– Uncle Billy
Jul 4 at 7:24





These questions are way too broad, and an answer will turn into a treatise, but for the last of them it's simple: GNU ls and grep do NOT care about the TERM variable, they simply assume that any terminal supports ANSI color escapes.

– Uncle Billy
Jul 4 at 7:24




1




1





You can use this occasion to submit a doc patch to gettext to fix the spelling of "cababilities" in that manual.

– Uncle Billy
Jul 4 at 7:53





You can use this occasion to submit a doc patch to gettext to fix the spelling of "cababilities" in that manual.

– Uncle Billy
Jul 4 at 7:53










2 Answers
2






active

oldest

votes


















8














The TERM variable is used by programs running in a terminal. It is supposed to allow programs to determine the capabilities of the terminal (or emulator) which is handling their output. It is documented in the ncurses manpage.



The terminal itself, including emulators such as xterm, doesn’t care about the value of TERM, beyond setting it (in the case of emulators — physical terminals can’t). It knows how to handle certain output sequences, and it handles them, without caring about TERM or anything else apart from its internal state. You can set TERM to anything you like in your shell, or even unset it, without changing the terminal’s behaviour; for a start, the terminal doesn’t know what TERM is set to!



Programs which care about TERM are typically those which use an output library which cares, such as ncurses, or in a more basic form Termcap or Terminfo. This includes shells such as Bash and Zsh, which use terminfo, for example for line editing features (being able to erase the line when you move up and down the history). These map the value of TERM to a database of capabilities, which tell the program or library whether the terminal can perform certain tasks (such as moving the cursor, clearing the screen, changing colours) and how to go about it. Some programs, such as GNU grep, assume capabilities without even checking.



Changing TERM from xterm-256color to xterm won’t change much, in particular it won’t disable colour support in programs which refer to TERM: xterm supports colour output too. The difference is in the number of colours which are supported.



See How do keyboard input and text output work?, Colors in Man Pages, Which terminal type am I using?, What protocol/standard is used by terminals? for more detail.






share|improve this answer

























  • Thanks for your answer. Do you know if there is any canonical documentation available for TERM variable? I can't really seem to find any. Since it is mentioned so often, I guess the variable is pretty "standardized"? for a start, the terminal doesn’t know what TERM is set to! - the terminal doesn't have access to an environment variable set in the shell, right? In ...how to determine a terminal’s capabilities, I guess you say the same thing twice? Does TERM determine if a program ouputs ANSI color escapes? Also, why doesn't the shell cares about TERM? It outputs text too (e.g. prompt)?

    – Shuzheng
    Jul 4 at 8:13







  • 1





    TERM is described in POSIX, but its values are unspecified; ncurses is possibly the best source of information nowadays. Yes, the terminal doesn’t have access to the shell’s environment variables. Determining capabilities and using features aren’t quite the same thing, although a decent terminal definition won’t say how to access features it doesn’t support ;-). Properly-written programs don’t know anything about ANSI escapes; they ask the terminal database how to do the things they want to do.

    – Stephen Kitt
    Jul 4 at 8:52






  • 1





    @StephenKitt most advanced shells (bash, zsh, ksh) will use terminal escapes to implement their line editing caps. They will consider the TERM envvar when doing it (zsh will even use xterm's mouse escapes to implement text selection itself -- better said to break the text selection by stuffing it with whitespace).

    – Uncle Billy
    Jul 4 at 9:18












  • @UncleBilly I stand corrected, I’ve updated the answer.

    – Stephen Kitt
    Jul 4 at 9:22






  • 2





    terminal emulators (and getty) are typically the ones that set the TERM env var.

    – Stéphane Chazelas
    Jul 4 at 9:26


















2














I'd say a lot of nCurses programs (and libtinfo ones) care about TERM.



One example would be htop, which often gives "partially-overwritten" lines when TERM=xterm, but everything looks OK when TERM=xterm-color.



From my experiences, programs that don't use libtinfo (either directly or indirectly, say via nCurses) usually don't care about TERM at all and assume support for color or cursor positioning, etc.






share|improve this answer

























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f528323%2fwhat-uses-the-term-variable%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    8














    The TERM variable is used by programs running in a terminal. It is supposed to allow programs to determine the capabilities of the terminal (or emulator) which is handling their output. It is documented in the ncurses manpage.



    The terminal itself, including emulators such as xterm, doesn’t care about the value of TERM, beyond setting it (in the case of emulators — physical terminals can’t). It knows how to handle certain output sequences, and it handles them, without caring about TERM or anything else apart from its internal state. You can set TERM to anything you like in your shell, or even unset it, without changing the terminal’s behaviour; for a start, the terminal doesn’t know what TERM is set to!



    Programs which care about TERM are typically those which use an output library which cares, such as ncurses, or in a more basic form Termcap or Terminfo. This includes shells such as Bash and Zsh, which use terminfo, for example for line editing features (being able to erase the line when you move up and down the history). These map the value of TERM to a database of capabilities, which tell the program or library whether the terminal can perform certain tasks (such as moving the cursor, clearing the screen, changing colours) and how to go about it. Some programs, such as GNU grep, assume capabilities without even checking.



    Changing TERM from xterm-256color to xterm won’t change much, in particular it won’t disable colour support in programs which refer to TERM: xterm supports colour output too. The difference is in the number of colours which are supported.



    See How do keyboard input and text output work?, Colors in Man Pages, Which terminal type am I using?, What protocol/standard is used by terminals? for more detail.






    share|improve this answer

























    • Thanks for your answer. Do you know if there is any canonical documentation available for TERM variable? I can't really seem to find any. Since it is mentioned so often, I guess the variable is pretty "standardized"? for a start, the terminal doesn’t know what TERM is set to! - the terminal doesn't have access to an environment variable set in the shell, right? In ...how to determine a terminal’s capabilities, I guess you say the same thing twice? Does TERM determine if a program ouputs ANSI color escapes? Also, why doesn't the shell cares about TERM? It outputs text too (e.g. prompt)?

      – Shuzheng
      Jul 4 at 8:13







    • 1





      TERM is described in POSIX, but its values are unspecified; ncurses is possibly the best source of information nowadays. Yes, the terminal doesn’t have access to the shell’s environment variables. Determining capabilities and using features aren’t quite the same thing, although a decent terminal definition won’t say how to access features it doesn’t support ;-). Properly-written programs don’t know anything about ANSI escapes; they ask the terminal database how to do the things they want to do.

      – Stephen Kitt
      Jul 4 at 8:52






    • 1





      @StephenKitt most advanced shells (bash, zsh, ksh) will use terminal escapes to implement their line editing caps. They will consider the TERM envvar when doing it (zsh will even use xterm's mouse escapes to implement text selection itself -- better said to break the text selection by stuffing it with whitespace).

      – Uncle Billy
      Jul 4 at 9:18












    • @UncleBilly I stand corrected, I’ve updated the answer.

      – Stephen Kitt
      Jul 4 at 9:22






    • 2





      terminal emulators (and getty) are typically the ones that set the TERM env var.

      – Stéphane Chazelas
      Jul 4 at 9:26















    8














    The TERM variable is used by programs running in a terminal. It is supposed to allow programs to determine the capabilities of the terminal (or emulator) which is handling their output. It is documented in the ncurses manpage.



    The terminal itself, including emulators such as xterm, doesn’t care about the value of TERM, beyond setting it (in the case of emulators — physical terminals can’t). It knows how to handle certain output sequences, and it handles them, without caring about TERM or anything else apart from its internal state. You can set TERM to anything you like in your shell, or even unset it, without changing the terminal’s behaviour; for a start, the terminal doesn’t know what TERM is set to!



    Programs which care about TERM are typically those which use an output library which cares, such as ncurses, or in a more basic form Termcap or Terminfo. This includes shells such as Bash and Zsh, which use terminfo, for example for line editing features (being able to erase the line when you move up and down the history). These map the value of TERM to a database of capabilities, which tell the program or library whether the terminal can perform certain tasks (such as moving the cursor, clearing the screen, changing colours) and how to go about it. Some programs, such as GNU grep, assume capabilities without even checking.



    Changing TERM from xterm-256color to xterm won’t change much, in particular it won’t disable colour support in programs which refer to TERM: xterm supports colour output too. The difference is in the number of colours which are supported.



    See How do keyboard input and text output work?, Colors in Man Pages, Which terminal type am I using?, What protocol/standard is used by terminals? for more detail.






    share|improve this answer

























    • Thanks for your answer. Do you know if there is any canonical documentation available for TERM variable? I can't really seem to find any. Since it is mentioned so often, I guess the variable is pretty "standardized"? for a start, the terminal doesn’t know what TERM is set to! - the terminal doesn't have access to an environment variable set in the shell, right? In ...how to determine a terminal’s capabilities, I guess you say the same thing twice? Does TERM determine if a program ouputs ANSI color escapes? Also, why doesn't the shell cares about TERM? It outputs text too (e.g. prompt)?

      – Shuzheng
      Jul 4 at 8:13







    • 1





      TERM is described in POSIX, but its values are unspecified; ncurses is possibly the best source of information nowadays. Yes, the terminal doesn’t have access to the shell’s environment variables. Determining capabilities and using features aren’t quite the same thing, although a decent terminal definition won’t say how to access features it doesn’t support ;-). Properly-written programs don’t know anything about ANSI escapes; they ask the terminal database how to do the things they want to do.

      – Stephen Kitt
      Jul 4 at 8:52






    • 1





      @StephenKitt most advanced shells (bash, zsh, ksh) will use terminal escapes to implement their line editing caps. They will consider the TERM envvar when doing it (zsh will even use xterm's mouse escapes to implement text selection itself -- better said to break the text selection by stuffing it with whitespace).

      – Uncle Billy
      Jul 4 at 9:18












    • @UncleBilly I stand corrected, I’ve updated the answer.

      – Stephen Kitt
      Jul 4 at 9:22






    • 2





      terminal emulators (and getty) are typically the ones that set the TERM env var.

      – Stéphane Chazelas
      Jul 4 at 9:26













    8












    8








    8







    The TERM variable is used by programs running in a terminal. It is supposed to allow programs to determine the capabilities of the terminal (or emulator) which is handling their output. It is documented in the ncurses manpage.



    The terminal itself, including emulators such as xterm, doesn’t care about the value of TERM, beyond setting it (in the case of emulators — physical terminals can’t). It knows how to handle certain output sequences, and it handles them, without caring about TERM or anything else apart from its internal state. You can set TERM to anything you like in your shell, or even unset it, without changing the terminal’s behaviour; for a start, the terminal doesn’t know what TERM is set to!



    Programs which care about TERM are typically those which use an output library which cares, such as ncurses, or in a more basic form Termcap or Terminfo. This includes shells such as Bash and Zsh, which use terminfo, for example for line editing features (being able to erase the line when you move up and down the history). These map the value of TERM to a database of capabilities, which tell the program or library whether the terminal can perform certain tasks (such as moving the cursor, clearing the screen, changing colours) and how to go about it. Some programs, such as GNU grep, assume capabilities without even checking.



    Changing TERM from xterm-256color to xterm won’t change much, in particular it won’t disable colour support in programs which refer to TERM: xterm supports colour output too. The difference is in the number of colours which are supported.



    See How do keyboard input and text output work?, Colors in Man Pages, Which terminal type am I using?, What protocol/standard is used by terminals? for more detail.






    share|improve this answer















    The TERM variable is used by programs running in a terminal. It is supposed to allow programs to determine the capabilities of the terminal (or emulator) which is handling their output. It is documented in the ncurses manpage.



    The terminal itself, including emulators such as xterm, doesn’t care about the value of TERM, beyond setting it (in the case of emulators — physical terminals can’t). It knows how to handle certain output sequences, and it handles them, without caring about TERM or anything else apart from its internal state. You can set TERM to anything you like in your shell, or even unset it, without changing the terminal’s behaviour; for a start, the terminal doesn’t know what TERM is set to!



    Programs which care about TERM are typically those which use an output library which cares, such as ncurses, or in a more basic form Termcap or Terminfo. This includes shells such as Bash and Zsh, which use terminfo, for example for line editing features (being able to erase the line when you move up and down the history). These map the value of TERM to a database of capabilities, which tell the program or library whether the terminal can perform certain tasks (such as moving the cursor, clearing the screen, changing colours) and how to go about it. Some programs, such as GNU grep, assume capabilities without even checking.



    Changing TERM from xterm-256color to xterm won’t change much, in particular it won’t disable colour support in programs which refer to TERM: xterm supports colour output too. The difference is in the number of colours which are supported.



    See How do keyboard input and text output work?, Colors in Man Pages, Which terminal type am I using?, What protocol/standard is used by terminals? for more detail.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jul 4 at 10:31

























    answered Jul 4 at 7:36









    Stephen KittStephen Kitt

    195k26 gold badges463 silver badges535 bronze badges




    195k26 gold badges463 silver badges535 bronze badges












    • Thanks for your answer. Do you know if there is any canonical documentation available for TERM variable? I can't really seem to find any. Since it is mentioned so often, I guess the variable is pretty "standardized"? for a start, the terminal doesn’t know what TERM is set to! - the terminal doesn't have access to an environment variable set in the shell, right? In ...how to determine a terminal’s capabilities, I guess you say the same thing twice? Does TERM determine if a program ouputs ANSI color escapes? Also, why doesn't the shell cares about TERM? It outputs text too (e.g. prompt)?

      – Shuzheng
      Jul 4 at 8:13







    • 1





      TERM is described in POSIX, but its values are unspecified; ncurses is possibly the best source of information nowadays. Yes, the terminal doesn’t have access to the shell’s environment variables. Determining capabilities and using features aren’t quite the same thing, although a decent terminal definition won’t say how to access features it doesn’t support ;-). Properly-written programs don’t know anything about ANSI escapes; they ask the terminal database how to do the things they want to do.

      – Stephen Kitt
      Jul 4 at 8:52






    • 1





      @StephenKitt most advanced shells (bash, zsh, ksh) will use terminal escapes to implement their line editing caps. They will consider the TERM envvar when doing it (zsh will even use xterm's mouse escapes to implement text selection itself -- better said to break the text selection by stuffing it with whitespace).

      – Uncle Billy
      Jul 4 at 9:18












    • @UncleBilly I stand corrected, I’ve updated the answer.

      – Stephen Kitt
      Jul 4 at 9:22






    • 2





      terminal emulators (and getty) are typically the ones that set the TERM env var.

      – Stéphane Chazelas
      Jul 4 at 9:26

















    • Thanks for your answer. Do you know if there is any canonical documentation available for TERM variable? I can't really seem to find any. Since it is mentioned so often, I guess the variable is pretty "standardized"? for a start, the terminal doesn’t know what TERM is set to! - the terminal doesn't have access to an environment variable set in the shell, right? In ...how to determine a terminal’s capabilities, I guess you say the same thing twice? Does TERM determine if a program ouputs ANSI color escapes? Also, why doesn't the shell cares about TERM? It outputs text too (e.g. prompt)?

      – Shuzheng
      Jul 4 at 8:13







    • 1





      TERM is described in POSIX, but its values are unspecified; ncurses is possibly the best source of information nowadays. Yes, the terminal doesn’t have access to the shell’s environment variables. Determining capabilities and using features aren’t quite the same thing, although a decent terminal definition won’t say how to access features it doesn’t support ;-). Properly-written programs don’t know anything about ANSI escapes; they ask the terminal database how to do the things they want to do.

      – Stephen Kitt
      Jul 4 at 8:52






    • 1





      @StephenKitt most advanced shells (bash, zsh, ksh) will use terminal escapes to implement their line editing caps. They will consider the TERM envvar when doing it (zsh will even use xterm's mouse escapes to implement text selection itself -- better said to break the text selection by stuffing it with whitespace).

      – Uncle Billy
      Jul 4 at 9:18












    • @UncleBilly I stand corrected, I’ve updated the answer.

      – Stephen Kitt
      Jul 4 at 9:22






    • 2





      terminal emulators (and getty) are typically the ones that set the TERM env var.

      – Stéphane Chazelas
      Jul 4 at 9:26
















    Thanks for your answer. Do you know if there is any canonical documentation available for TERM variable? I can't really seem to find any. Since it is mentioned so often, I guess the variable is pretty "standardized"? for a start, the terminal doesn’t know what TERM is set to! - the terminal doesn't have access to an environment variable set in the shell, right? In ...how to determine a terminal’s capabilities, I guess you say the same thing twice? Does TERM determine if a program ouputs ANSI color escapes? Also, why doesn't the shell cares about TERM? It outputs text too (e.g. prompt)?

    – Shuzheng
    Jul 4 at 8:13






    Thanks for your answer. Do you know if there is any canonical documentation available for TERM variable? I can't really seem to find any. Since it is mentioned so often, I guess the variable is pretty "standardized"? for a start, the terminal doesn’t know what TERM is set to! - the terminal doesn't have access to an environment variable set in the shell, right? In ...how to determine a terminal’s capabilities, I guess you say the same thing twice? Does TERM determine if a program ouputs ANSI color escapes? Also, why doesn't the shell cares about TERM? It outputs text too (e.g. prompt)?

    – Shuzheng
    Jul 4 at 8:13





    1




    1





    TERM is described in POSIX, but its values are unspecified; ncurses is possibly the best source of information nowadays. Yes, the terminal doesn’t have access to the shell’s environment variables. Determining capabilities and using features aren’t quite the same thing, although a decent terminal definition won’t say how to access features it doesn’t support ;-). Properly-written programs don’t know anything about ANSI escapes; they ask the terminal database how to do the things they want to do.

    – Stephen Kitt
    Jul 4 at 8:52





    TERM is described in POSIX, but its values are unspecified; ncurses is possibly the best source of information nowadays. Yes, the terminal doesn’t have access to the shell’s environment variables. Determining capabilities and using features aren’t quite the same thing, although a decent terminal definition won’t say how to access features it doesn’t support ;-). Properly-written programs don’t know anything about ANSI escapes; they ask the terminal database how to do the things they want to do.

    – Stephen Kitt
    Jul 4 at 8:52




    1




    1





    @StephenKitt most advanced shells (bash, zsh, ksh) will use terminal escapes to implement their line editing caps. They will consider the TERM envvar when doing it (zsh will even use xterm's mouse escapes to implement text selection itself -- better said to break the text selection by stuffing it with whitespace).

    – Uncle Billy
    Jul 4 at 9:18






    @StephenKitt most advanced shells (bash, zsh, ksh) will use terminal escapes to implement their line editing caps. They will consider the TERM envvar when doing it (zsh will even use xterm's mouse escapes to implement text selection itself -- better said to break the text selection by stuffing it with whitespace).

    – Uncle Billy
    Jul 4 at 9:18














    @UncleBilly I stand corrected, I’ve updated the answer.

    – Stephen Kitt
    Jul 4 at 9:22





    @UncleBilly I stand corrected, I’ve updated the answer.

    – Stephen Kitt
    Jul 4 at 9:22




    2




    2





    terminal emulators (and getty) are typically the ones that set the TERM env var.

    – Stéphane Chazelas
    Jul 4 at 9:26





    terminal emulators (and getty) are typically the ones that set the TERM env var.

    – Stéphane Chazelas
    Jul 4 at 9:26













    2














    I'd say a lot of nCurses programs (and libtinfo ones) care about TERM.



    One example would be htop, which often gives "partially-overwritten" lines when TERM=xterm, but everything looks OK when TERM=xterm-color.



    From my experiences, programs that don't use libtinfo (either directly or indirectly, say via nCurses) usually don't care about TERM at all and assume support for color or cursor positioning, etc.






    share|improve this answer



























      2














      I'd say a lot of nCurses programs (and libtinfo ones) care about TERM.



      One example would be htop, which often gives "partially-overwritten" lines when TERM=xterm, but everything looks OK when TERM=xterm-color.



      From my experiences, programs that don't use libtinfo (either directly or indirectly, say via nCurses) usually don't care about TERM at all and assume support for color or cursor positioning, etc.






      share|improve this answer

























        2












        2








        2







        I'd say a lot of nCurses programs (and libtinfo ones) care about TERM.



        One example would be htop, which often gives "partially-overwritten" lines when TERM=xterm, but everything looks OK when TERM=xterm-color.



        From my experiences, programs that don't use libtinfo (either directly or indirectly, say via nCurses) usually don't care about TERM at all and assume support for color or cursor positioning, etc.






        share|improve this answer













        I'd say a lot of nCurses programs (and libtinfo ones) care about TERM.



        One example would be htop, which often gives "partially-overwritten" lines when TERM=xterm, but everything looks OK when TERM=xterm-color.



        From my experiences, programs that don't use libtinfo (either directly or indirectly, say via nCurses) usually don't care about TERM at all and assume support for color or cursor positioning, etc.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jul 4 at 7:42









        iBugiBug

        1,10911 silver badges32 bronze badges




        1,10911 silver badges32 bronze badges



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f528323%2fwhat-uses-the-term-variable%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

            Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

            Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림