Windows Terminal dependent PowerShell prompt

Windows Terminal gets more and more my standard-tool to interact with PowerShell. Beneath all the cool built-in-features, it allows pretty fonts, characters and therefor a very unique prompt, supported by oh-my-posh and posh-git.

During the setup of those 2 great tools, i figured out that oh-my-posh doesnt work with the standard pwsh.exe prompt. Special characters dont get rendered correctly. So i found a way to decide which prompt to use depending on beeing started in Windows Terminal or not.

The magic differnec is that in Windows Terminal exists a variable called WSLENV with the value WT_SESSION:.

So in my profile i added this little piece of code.

Now i have the correct prompt in native pwsh.exe and Windows Terminal.

Cheers / Roman