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"
}
elseif (Test-Path $Theme) {
$config = Resolve-Path -Path $Theme
$config = (Resolve-Path -Path $Theme).Path
}
else {
$config = "$PSScriptRoot/themes/jandedobbeleer.omp.json"
}
$poshCommand = Get-PoshCommand
Invoke-Expression (& $poshCommand --init --shell pwsh --config $config)
Invoke-Expression (& $poshCommand --init --shell=pwsh --config="$config")
}
function Get-PoshThemes {

View file

@ -2,8 +2,9 @@ $global:PoshSettings = New-Object -TypeName PSObject -Property @{
Theme = "";
}
if (Test-Path "::CONFIG::") {
$global:PoshSettings.Theme = Resolve-Path -Path "::CONFIG::"
$config = "::CONFIG::"
if (Test-Path $config) {
$global:PoshSettings.Theme = (Resolve-Path -Path $config).Path
}
function global:Set-PoshContext {}
@ -44,7 +45,7 @@ function global:Set-PoshGitStatus {
$config = $global:PoshSettings.Theme
$cleanPWD = $PWD.ProviderPath.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
[Console]::OutputEncoding = $originalOutputEncoding
# 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 {
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:
return printShellInit(shell, config)
default: