Skip to content

Commit

Permalink
Merge pull request #1060 from carapace-sh/elvish-exe-completion
Browse files Browse the repository at this point in the history
elvish: register `.exe` completion on windows
  • Loading branch information
rsteube authored Dec 24, 2024
2 parents e76b528 + a0a6f1f commit 49b6747
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/shell/elvish/snippet.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package elvish

import (
"fmt"
"runtime"

"github.com/carapace-sh/carapace/pkg/uid"
"github.com/spf13/cobra"
)

// Snippet creates the elvish completion script.
func Snippet(cmd *cobra.Command) string {
return fmt.Sprintf(`set edit:completion:arg-completer[%v] = {|@arg|
result := fmt.Sprintf(`set edit:completion:arg-completer[%v] = {|@arg|
%v _carapace elvish (all $arg) | from-json | each {|completion|
put $completion[Messages] | all (one) | each {|m|
edit:notify (styled "error: " red)$m
Expand All @@ -28,4 +29,9 @@ func Snippet(cmd *cobra.Command) string {
}
}
`, cmd.Name(), uid.Executable())

if runtime.GOOS == "windows" {
result += fmt.Sprintf("set edit:completion:arg-completer[%v.exe] = $edit:completion:arg-completer[%v]\n", cmd.Name(), cmd.Name())
}
return result
}

0 comments on commit 49b6747

Please sign in to comment.