Skip to content

Commit

Permalink
fix(pwsh): provide full config path
Browse files Browse the repository at this point in the history
resolves #355
  • Loading branch information
JanDeDobbeleer committed Jan 18, 2021
1 parent f6501ae commit d0256b8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/powershell/oh-my-posh/oh-my-posh.psm1
Expand Up @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions src/init/omp.ps1
Expand Up @@ -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 {}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/main.go
Expand Up @@ -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:
Expand Down

0 comments on commit d0256b8

Please sign in to comment.