fix(pwsh): provide full config path

resolves #355
This commit is contained in:
Jan De Dobbeleer 2021-01-18 18:58:17 +01:00 committed by Jan De Dobbeleer
parent f6501aeb51
commit b651c9a065
3 changed files with 7 additions and 6 deletions

View file

@ -32,14 +32,14 @@ function Set-PoshPrompt {
$config = "$PSScriptRoot/themes/$Theme.omp.json" $config = "$PSScriptRoot/themes/$Theme.omp.json"
} }
elseif (Test-Path $Theme) { elseif (Test-Path $Theme) {
$config = Resolve-Path -Path $Theme $config = (Resolve-Path -Path $Theme).Path
} }
else { else {
$config = "$PSScriptRoot/themes/jandedobbeleer.omp.json" $config = "$PSScriptRoot/themes/jandedobbeleer.omp.json"
} }
$poshCommand = Get-PoshCommand $poshCommand = Get-PoshCommand
Invoke-Expression (& $poshCommand --init --shell pwsh --config $config) Invoke-Expression (& $poshCommand --init --shell=pwsh --config="$config")
} }
function Get-PoshThemes { function Get-PoshThemes {

View file

@ -2,8 +2,9 @@ $global:PoshSettings = New-Object -TypeName PSObject -Property @{
Theme = ""; Theme = "";
} }
if (Test-Path "::CONFIG::") { $config = "::CONFIG::"
$global:PoshSettings.Theme = Resolve-Path -Path "::CONFIG::" if (Test-Path $config) {
$global:PoshSettings.Theme = (Resolve-Path -Path $config).Path
} }
function global:Set-PoshContext {} function global:Set-PoshContext {}
@ -44,7 +45,7 @@ function global:Set-PoshGitStatus {
$config = $global:PoshSettings.Theme $config = $global:PoshSettings.Theme
$cleanPWD = $PWD.ProviderPath.TrimEnd("\") $cleanPWD = $PWD.ProviderPath.TrimEnd("\")
$cleanPSWD = $PWD.ToString().TrimEnd("\") $cleanPSWD = $PWD.ToString().TrimEnd("\")
$standardOut = @(&$omp "--config=$config" "--error=$errorCode" "--pwd=$cleanPWD" "--pswd=$cleanPSWD" "--execution-time=$executionTime") $standardOut = @(&$omp --error="$errorCode" --pwd="$cleanPWD" --pswd="$cleanPSWD" --execution-time="$executionTime" --config="$config")
# Restore initial encoding # Restore initial encoding
[Console]::OutputEncoding = $originalOutputEncoding [Console]::OutputEncoding = $originalOutputEncoding
# the ouput can be multiline, joining these ensures proper rendering by adding line breaks with `n # the ouput can be multiline, joining these ensures proper rendering by adding line breaks with `n

View file

@ -167,7 +167,7 @@ func initShell(shell, config string) string {
} }
switch shell { switch shell {
case pwsh: case pwsh:
return fmt.Sprintf("Invoke-Expression (@(&\"%s\" --print-init --shell pwsh --config %s) -join \"`n\")", executable, config) return fmt.Sprintf("Invoke-Expression (@(&\"%s\" --print-init --shell=pwsh --config=\"%s\") -join \"`n\")", executable, config)
case zsh, bash, fish: case zsh, bash, fish:
return printShellInit(shell, config) return printShellInit(shell, config)
default: default: