Skip to content

Commit

Permalink
powershell: support exe extension
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Nov 5, 2024
1 parent 1209a8d commit 4e5d907
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions cmd/carapace/cmd/lazyinit/powershell.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package lazyinit

import (
"fmt"
"runtime"
"strings"
)

Expand All @@ -16,9 +17,16 @@ $_carapace_lazy = {
}
%v
`
complete := make([]string, len(completers))
for index, completer := range completers {
complete[index] = fmt.Sprintf(`Register-ArgumentCompleter -Native -CommandName '%v' -ScriptBlock $_carapace_lazy`, completer)

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))
}
return fmt.Sprintf(snippet, pathSnippet("powershell"), envSnippet("powershell"), strings.Join(complete, "\n"))
}

0 comments on commit 4e5d907

Please sign in to comment.