mirror of
https://github.com/rsteube/carapace-bin.git
synced 2025-05-05 23:42:54 +00:00
powershell: support exe
extension
This commit is contained in:
parent
1209a8d1d8
commit
51df8e491c
@ -2,6 +2,7 @@ package lazyinit
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -10,15 +11,21 @@ func Powershell(completers []string) string {
|
|||||||
|
|
||||||
$_carapace_lazy = {
|
$_carapace_lazy = {
|
||||||
param($wordToComplete, $commandAst, $cursorPosition)
|
param($wordToComplete, $commandAst, $cursorPosition)
|
||||||
$completer = $commandAst.CommandElements[0].Value
|
$completer = $commandAst.CommandElements[0].Value.trimend(".exe")
|
||||||
carapace $completer powershell | Out-String | Invoke-Expression
|
carapace $completer powershell | Out-String | Invoke-Expression
|
||||||
& (Get-Item "Function:_${completer}_completer") $wordToComplete $commandAst $cursorPosition
|
& (Get-Item "Function:_${completer}_completer") $wordToComplete $commandAst $cursorPosition
|
||||||
}
|
}
|
||||||
%v
|
%v
|
||||||
`
|
`
|
||||||
complete := make([]string, len(completers))
|
|
||||||
for index, completer := range completers {
|
prefix := " # "
|
||||||
complete[index] = fmt.Sprintf(`Register-ArgumentCompleter -Native -CommandName '%v' -ScriptBlock $_carapace_lazy`, completer)
|
if runtime.GOOS == "windows" {
|
||||||
|
prefix = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
complete := make([]string, 0, len(completers)*2)
|
||||||
|
for _, completer := range completers {
|
||||||
|
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"))
|
return fmt.Sprintf(snippet, pathSnippet("powershell"), envSnippet("powershell"), strings.Join(complete, "\n"))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user