File tree Expand file tree Collapse file tree
static/skills/ohmyposh/shell Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -217,16 +217,18 @@ to only require remote scripts to be signed using `Set-ExecutionPolicy -Executio
217217Add the following snippet as the last line to your PowerShell profile script:
218218
219219``` powershell
220- oh-my-posh init pwsh | Invoke-Expression
220+ $(if (Get-Command 'oh-my-posh' -ErrorAction Ignore) {
221+ oh-my-posh init pwsh
222+ # Set output encoding to UTF-8
223+ [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
224+ # Set input encoding to UTF-8 (for reading user input with non-ASCII chars)
225+ [Console]::InputEncoding = [System.Text.Encoding]::UTF8
226+ }) | Invoke-Expression
221227```
222228
223229:::tip Execution policy
224230In case the execution policy disables executing unsigned scripts on your system, you can fallback to evaluating
225- the script instead. Use the ` --eval ` flag to do so:
226-
227- ``` powershell
228- oh-my-posh init pwsh --eval | Invoke-Expression
229- ```
231+ the script instead. Add the ` --eval ` flag to the ` oh-my-posh init pwsh ` command above.
230232
231233Be aware this will make initializing the shell slower.
232234:::
Original file line number Diff line number Diff line change @@ -18,7 +18,13 @@ notepad $PROFILE
1818Add this as the ** last line** :
1919
2020``` powershell
21- oh-my-posh init pwsh | Invoke-Expression
21+ $(if (Get-Command 'oh-my-posh' -ErrorAction Ignore) {
22+ oh-my-posh init pwsh
23+ # Set output encoding to UTF-8
24+ [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
25+ # Set input encoding to UTF-8 (for reading user input with non-ASCII chars)
26+ [Console]::InputEncoding = [System.Text.Encoding]::UTF8
27+ }) | Invoke-Expression
2228```
2329
2430Reload the profile:
@@ -35,11 +41,7 @@ Reload the profile:
3541Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
3642```
3743
38- Or use the ` --eval ` flag (slightly slower startup):
39-
40- ``` powershell
41- oh-my-posh init pwsh --eval | Invoke-Expression
42- ```
44+ Or add the ` --eval ` flag to the ` oh-my-posh init pwsh ` command above (slightly slower startup).
4345
4446## Next step
4547
You can’t perform that action at this time.
0 commit comments