diff --git a/pkg/bridges/zsh.go b/pkg/bridges/zsh.go index 202529c..42c638d 100644 --- a/pkg/bridges/zsh.go +++ b/pkg/bridges/zsh.go @@ -1,6 +1,7 @@ package bridges import ( + "fmt" "os" "runtime" "sort" @@ -8,6 +9,7 @@ import ( "github.com/carapace-sh/carapace" "github.com/carapace-sh/carapace/pkg/execlog" + "github.com/carapace-sh/carapace/pkg/xdg" ) func Zsh() []string { @@ -20,8 +22,16 @@ func Zsh() []string { } return cache("zsh", func() ([]string, error) { - out, err := execlog.Command("zsh", "--no-rcs", "-c", "printf '%s\n' $fpath").Output() - if err != nil { + script := "printf '%s\n' $fpath" + if configDir, err := xdg.UserConfigDir(); err == nil { + zshrc := configDir + "/carapace/bridge/zsh/.zshrc" + if _, err := os.Stat(zshrc); err == nil { + script = fmt.Sprintf("source %v;%v", zshrc, script) + } + } + + out, err := execlog.Command("zsh", "--no-rcs", "-c", script).Output() + if err != nil { // TODO log stderr return nil, err } lines := strings.Split(string(out), "\n")