I'm writing a new PowerShell script, and I want to make use of unicode emojies, which are now supported by the new Windows Terminal Preview. However, for a user running "legacy" PowerShell that doesn't support it, I do not wish to show the unrecognized characters, and instead I would like to show him some other text/sign.
To be more simple - I would like to know when my PS script is running in the new Terminal and show one thing and show something else for other PS terminals.
I have tried using $env:TERM_PROGRAM
. If I use is inside the vscode PS terminal it returns "vscode", but under normal PS terminal or new terminal it returns nothing.
Any ideas?
Windows Terminal is still in its infancy and not much to go by to identify it but I noticed that it adds an environment variable WT_SESSION, you might try checking for that:
if ($env:WT_SESSION) {
"I am in Windows Terminal"
} else {
"Nothing to see here..."
}