Skip to content

Commit

Permalink
Merge pull request #2662 from carapace-sh/nushell-exe-completion
Browse files Browse the repository at this point in the history
nushell: support `.exe` completion on windows
  • Loading branch information
rsteube authored Dec 24, 2024
2 parents a738ad1 + b328333 commit 97f25bd
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions cmd/carapace/cmd/lazyinit/nushell.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
package lazyinit

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

func Nushell(completers []string) string {
windowsSnippet := ""
if runtime.GOOS == "windows" {
windowsSnippet = " | str replace --regex '\\.exe$' ''"
}
snippet := `%v%v
let carapace_completer = {|spans|
Expand All @@ -12,9 +19,9 @@ let carapace_completer = {|spans|
# overwrite
let spans = (if $expanded_alias != null {
# put the first word of the expanded alias first in the span
$spans | skip 1 | prepend ($expanded_alias | split row " " | take 1)
$spans | skip 1 | prepend ($expanded_alias | split row " " | take 1%v)
} else {
$spans
$spans | skip 1 | prepend ($spans.0%v)
})
carapace $spans.0 nushell ...$spans
Expand All @@ -30,5 +37,5 @@ $current.completions.external = ($current.completions.external
$env.config = $current
`

return fmt.Sprintf(snippet, pathSnippet("nushell"), envSnippet("nushell"))
return fmt.Sprintf(snippet, pathSnippet("nushell"), envSnippet("nushell"), windowsSnippet, windowsSnippet)
}

0 comments on commit 97f25bd

Please sign in to comment.