When PowerShell is launched via Windows Terminal it has much cleaner formatting and ANSI escape sequences (color, cursor positioning, etc.) are rendered correctly. I have a console application that makes extensive use of these features. Think of it as an application-specific text editor that needs full control of the console output and rendering under Windows.
I am using Pyinstaller to package the application into an exe. From there I will create an MSI for installation. However, I need to make sure that the console launched by Pyinstaller will actually render the text correctly, which includes rendering ANSI escape sequences to control color, cursor and text positioning, etc.
One way I can think of would be to have Pyinstaller launch Windows Terminal instead. The other way might be to launch PowerShell through some kind of a configuration file that would cause it to behave as it does under Windows Terminal. Not sure if I can control PowerShell from Python for the purpose of setting-up how it behaves in this regard.
Please note:
This is not about how to enable ANSI escape sequences on PowerShell. This is not a duplicate of that question.
This is about the fact that PowerShell behaves differently when launched by itself vs. launching under Windows Terminal. At a very basic level, the font and font sizes are different, the window size is different, ANSI escape sequences don't work and who knows what else. Not sure what else is different. Buffer size? Path? Any other defaults? Still investigating.
Can't post a reproducible example because, well, this is in the context of a full Windows 10 install. I can't post a bit of code that makes this happen, it's an OS issue.
At the core this is about how to have/force the same experience regardless of where or how you might launch PowerShell.
Also, this is not about being able to manually launch a script after manually launching PowerShell under Windows Terminal. The objective is to have the same default behavior so that one can package a Python application using Pyinstaller, create an MSI and, ultimately, have an icon on the desktop that a non-developer can double-click and launch the application as intended.
EDIT:
I was able to accomplish this by having the MSI installation script create a desktop icon that calls a batch file, rather than the exe
created by Pyinstaller. The batch file executes the exe in the context of Windows Terminal, like this:
@echo off
wt.exe <something.exe>
While this works, it would be much better if there was a way to have Pyinstaller produce an exe that actually launches a console application using Windows Terminal, which delivers a far better PowerShell experience with greater capabilities. Either that, or find a way to have stand-alone PowerShell match PowerShell under Windows Terminal.