fix(pwsh): keep a working version

This commit is contained in:
Jan De Dobbeleer 2022-04-26 08:22:34 +02:00 committed by Jan De Dobbeleer
parent f8e5ff5be4
commit 7540a5e3b2
2 changed files with 22 additions and 1 deletions

View file

@ -43,7 +43,7 @@ See your platform's installation guide. The preferred ways are **winget** and **
### Uninstall the PowerShell module
```powershell
Uninstall-Module oh-my-posh --AllVersions
Uninstall-Module oh-my-posh -AllVersions
```
Delete the import of the PowerShell module in your `$PROFILE`

View file

@ -59,6 +59,8 @@ function Set-PoshRootPath {
}
Set-PoshRootPath
$env:PATH = $env:POSH_PATH + [System.IO.Path]::PathSeparator + $env:PATH
$env:POSH_THEMES_PATH = Join-Path -Path $env:POSH_PATH -ChildPath "themes"
function Set-PoshPrompt {
param(
@ -66,4 +68,23 @@ function Set-PoshPrompt {
[string]
$Theme
)
$config = ""
if (Test-Path "$($env:POSH_THEMES_PATH)/$Theme.omp.json") {
$path = "$($env:POSH_THEMES_PATH)/$Theme.omp.json"
$config = (Resolve-Path -Path $path).ProviderPath
}
elseif (Test-Path $Theme) {
$config = (Resolve-Path -Path $Theme).ProviderPath
}
else {
$config = "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/v7.71.2/themes/default.omp.json"
}
# Workaround for get-location/push-location/pop-location from within a module
# https://github.com/PowerShell/PowerShell/issues/12868
# https://github.com/JanDeDobbeleer/oh-my-posh2/issues/113
$global:OMP_GLOBAL_SESSIONSTATE = $PSCmdlet.SessionState
oh-my-posh init pwsh --config="$config" | Invoke-Expression
}