Search code examples
shellcommand-lineenvironment-variableswindows-terminal

How to determine if the terminal is a windows terminal


How to determine if the terminal is a windows terminal.

I want to enabled ANSI output in windows terminal and disenabled in CMD.

Is it possible to judge through environmental variables? like:

What is the best practice?


Solution

  • You can check if the environment variables WT_PROFILE_ID or WT_SESSION are present.