pyenv/completions/pyenv.pwsh
Florian Blanchet aeea3ac825
Add PowerShell support (#2749)
Co-authored-by: Ivan Pozdeev <ivan_pozdeev@mail.ru>
Co-authored-by: Ivan Pozdeev <vano@mail.mipt.ru>
2025-12-21 05:33:19 +03:00

18 lines
713 B
Plaintext

$scriptblock = {
param($wordToComplete, $commandAst, $cursorPosition)
$words = $commandAst.ToString()
if ( $wordToComplete ) {
$matches = (($words[0..$cursorPosition] -join '') | Select-String -Pattern "\s+" -AllMatches).Matches
if ( $matches ) {
$cursorPosition = $matches[-1].Index - 1
}
}
$words = $words[0..$cursorPosition] -join '' -split "\s+"
if ( $words.Count -ge 2 ) {
pyenv completions $words[1] | where { $_ -match $wordToComplete }
} else {
pyenv commands | where { $_ -match $wordToComplete }
}
}
Register-ArgumentCompleter -Native -CommandName pyenv -ScriptBlock $scriptblock