abra/autocomplete/powershell_autocomplete.ps1
knoflook 1757fabb89
All checks were successful
continuous-integration/drone/pr Build is passing
feat: bash and (fi)zsh completion along with docs
2021-09-07 13:18:21 +02:00

9 lines
426 B
PowerShell

$fn = $($MyInvocation.MyCommand.Name)
$name = $fn -replace "(.*)\.ps1$", '$1'
Register-ArgumentCompleter -Native -CommandName $name -ScriptBlock {
param($commandName, $wordToComplete, $cursorPosition)
$other = "$wordToComplete --generate-bash-completion"
Invoke-Expression $other | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}