Closed borren closed 2 years ago
Where it comes from: https://github.com/JanDeDobbeleer/oh-my-posh/pull/528
~~By default, powershell core switched to utf8nobom(https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_character_encoding?view=powershell-7.1).
This is used for regular powershell:~~
# Powershell doesn't default to UTF8 just yet, so we're forcing it as there are too many problems
# that pop up when we don't
[console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
so if you're using powershell core, maybe an extra step could be done to do a check before doing this. But if it's a regular powershell window, I'm not sure we can avoid this.
for info, I checked without setting the encoding, and even with the latest version of powershell core my encoding is not set to utf-8.
and with powershell 5.1:
@lnu @borren I can set the env vars using Set-Content -Path $Name -Value $false
, that's an easy fix. But for the encoding I just don't seem to find a way.
@borren I have no alternative for setting UTF-8 correctly. Is it an option for you to set $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage"
after importing oh-my-posh?
@borren I have no alternative for setting UTF-8 correctly. Is it an option for you to set
$ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage"
after importing oh-my-posh?
It seems it can be enforced using policies so in that case you have no choice.
Could chcp 65001
be an alternative? Not tested yet but it seems it changes output and input encoding of the console.
=> nope, it does not work...
@borren I have no alternative for setting UTF-8 correctly. Is it an option for you to set
$ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage"
after importing oh-my-posh? It is no problem in itself. The setting is forced by policy in my case (but as local admin i can work around it).But it would be nice to not have to run in elevated mode on corporate controlled computers that has a little more security. I can do some digging of my own when i get som e playtime. The fixes for setting env:vars is a good leap forward. Wish powershell wasnt so picky when running $PROFILE scripts, if it is a normal script, signing it is enough for it to work. But one key point in using your beloved oh-my-posh is that it gets loaded by the profile :)
This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. If you have found a problem that seems similar, please open a discussion first, complete the body with all the details necessary to reproduce, and mention this issue as reference.
Code of Conduct
What happened?
With security tightening by the week nowdays, you should really join us who are trying our best to stay in a non elevated prompt! Running powershell in Constrained languagemode does not permit the use of [any.system.class]::invocationcall but for the base functionality it seems there are only a few of those methods in use.![bild](https://user-images.githubusercontent.com/3264743/138217078-95b5aa09-c00a-46ea-88b8-932997e15950.png)
All the EnvironmentVariable handling should be really easy to take care of with regular powershell functions with the help of $ENV:varname and/or in combination with Set-Item
Not sure about how to solve the [console]::OutputEncoding = New-Object System.Text.UTF8Encoding, i havent looked at the sourcecode. But i think there should is a simple solution för that as well, without having to invoke a .sourced class.
Love your work!! /borren
Version
5.10.1
Theme
default jandedobbeleer.omp.json and my custom theme are both affected :)
What OS are you seeing the problem on?
Windows
Which shell are you using?
powershell
Relevant log output