@@ -2,6 +2,7 @@ package bridges
22
33import (
44 "bytes"
5+ _ "embed"
56 "fmt"
67 "os"
78 "runtime"
@@ -13,6 +14,9 @@ import (
1314 "github.com/carapace-sh/carapace/pkg/xdg"
1415)
1516
17+ //go:embed zsh.sh
18+ var zshScript string
19+
1620func Zsh () []string {
1721 if runtime .GOOS == "windows" {
1822 return []string {}
@@ -23,7 +27,7 @@ func Zsh() []string {
2327 }
2428
2529 return cache ("zsh" , func () ([]string , error ) {
26- script := "printf '%s \n ' $fpath"
30+ script := zshScript
2731 if path , err := zshrc (); err == nil {
2832 script = fmt .Sprintf ("autoload -U compinit && compinit;source %#v;%v;compinit" , path , script )
2933 }
@@ -39,19 +43,12 @@ func Zsh() []string {
3943 }
4044 return nil , err
4145 }
42- lines := strings .Split (stdout .String (), "\n " )
4346
47+ lines := strings .Split (stdout .String (), "\n " )
4448 unique := make (map [string ]bool )
4549 for _ , line := range lines {
46- entries , err := os .ReadDir (line )
47- if err != nil {
48- carapace .LOG .Println (err .Error ())
49- continue
50- }
51- for _ , entry := range entries {
52- if ! entry .IsDir () && strings .HasPrefix (entry .Name (), "_" ) {
53- unique [strings .TrimPrefix (entry .Name (), "_" )] = true
54- }
50+ if line != "" {
51+ unique [line ] = true // TODO map still necessary?
5552 }
5653 }
5754
0 commit comments