Open JustinGrote opened 2 months ago
SpectreConsole checks terminal capabilities on import and sets a profile.
try running this before you import the module.
$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = [System.Text.UTF8Encoding]::new()
i could replicate your issue in my extension terminal, i had forgot to set UTF8 in my vscode profile.
after setting that and restarting the terminal emojis worked.
if it still doesn't work, could you share the output of the below command?
& (gmo PwshSpectreConsole) { Get-SpectreProfile }
That does fix it! Interesting. Would it be worth autodetecting some terminals we know have unicode support and enable this? E.g. Windows Terminal can be detected with WT_PROFILE_ID env variable
EDIT: Related: https://github.com/PowerShell/PowerShell/issues/7233
yea showing a warning on import if someone isn't running utf8 would probably save a few people some headache.
I'm not sure changing someones codepage would be nice? there are some edge cases around WSL and similar that dont mix too well with UTF8.
But utf8 should just be the default one by now...
also at the point we could detect it Spectre has already set the profile..
and it does not appear to be entirely straightforward to force it to utf8 after the fact.. but i've only done some brief tests, maybe there is a way to get it to re-run "discovery".
right side has utf8 before import, just to show the profile
Yeah I'd say warning with a ENV variable or global setting to suppress it is probably the way to go.
But utf8 should just be the default one by now...
I've been hoping windows terminal just bites the bullet and sets this. The annoying part is you need to include that snippet as the very first thing in the profile to avoid any other command generating output before setting the encoding settings.
When I've got some time to tinker I think I'll update the module to detect this and maybe offer something like these options on the first run:
Leave my profile alone, I know I'm going to have a degraded experience
I avoided touching peoples encoding settings originally but it's kind of so odd to have to set up that it might be worth it.
PS> pwsh -nop -c 'ipmo .\PwshSpectreConsole\PwshSpectreConsole\PwshSpectreConsole.psd1'
WARNING: Your session is currently using encoding 'OEM United States', this disables certain functionality as SpectreConsole requires UTF8 encoding, consider adding
'$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = [System.Text.UTF8Encoding]::new()' to your $profile
to suppress this warning set the environment variable '$env:IgnoreSpectreEncoding=$true'
Note: this needs to be set before importing the module
this covers the basics atleast.
it'll be in once #50 is merged.
It should spit out a pretty obvious warning now in prerelease...
PWSH 7.4, Windows Terminal, also happens in vscode. PwshSpectreConsole 2.1.1