Skip to content

Commit

Permalink
Merge pull request #2587 from carapace-sh/powershell-list
Browse files Browse the repository at this point in the history
powershell: register with list
  • Loading branch information
rsteube authored Nov 8, 2024
2 parents 202a3ed + fafc1fa commit d1a318b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions cmd/carapace/cmd/lazyinit/powershell.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,21 @@ func Powershell(completers []string) string {
$_carapace_lazy = {
param($wordToComplete, $commandAst, $cursorPosition)
$completer = $commandAst.CommandElements[0].Value
$completer = $commandAst.CommandElements[0].Value.trimend(".exe")
carapace $completer powershell | Out-String | Invoke-Expression
& (Get-Item "Function:_${completer}_completer") $wordToComplete $commandAst $cursorPosition
}
%v
`

prefix := "# "
prefix := " # "
if runtime.GOOS == "windows" {
prefix = ""
}

complete := make([]string, 0, len(completers)*2)
for _, completer := range completers {
complete = append(complete, fmt.Sprintf(`Register-ArgumentCompleter -Native -CommandName '%v' -ScriptBlock $_carapace_lazy`, completer))
complete = append(complete, fmt.Sprintf(`%vRegister-ArgumentCompleter -Native -CommandName '%v.exe' -ScriptBlock $_carapace_lazy`, prefix, completer))
complete = append(complete, fmt.Sprintf(`Register-ArgumentCompleter -Native -ScriptBlock $_carapace_lazy -CommandName '%v'%v,'%v.exe'`, completer, prefix, completer))
}
return fmt.Sprintf(snippet, pathSnippet("powershell"), envSnippet("powershell"), strings.Join(complete, "\n"))
}

0 comments on commit d1a318b

Please sign in to comment.