kelleyma49 / PSFzf

A PowerShell wrapper around the fuzzy finder fzf
MIT License
787 stars 34 forks source link

Error : pwsh not found / Powershell 5 compatibility #102

Closed belotn closed 2 years ago

belotn commented 2 years ago

Hello,

i have host with only powershell 5 and some host with powershell 7 outside of defaut path, in this case, Preview failed with "pwsh not found".

one way to correct it is to check if pwsh is in path and use the avaiable powershell executable in Path.

if(Get-Command pswh -ErrorAction SilentlyContinue){
    $PowerShellCMD='pwsh'
}elseif( Get-Command powershell -ErrorAction SilentlyContinue){
    $PowerShellCMD='powershell'
}
#(...)
        $additionalCmd = @{ Preview=$("$PowerShellCMD -NoProfile -NonInteractive -File \""$previewScript\"" \""" + $path + "\"" {}") }