Skip to content

Commit

Permalink
elvish: register .exe completion on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Dec 24, 2024
1 parent e76b528 commit a0a6f1f
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 a0a6f1f

Please sign in to comment.