Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion cmd/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func installers() (i []installer) {
break
}
}
if f := rcFile(".zshrc"); f != "" {
if f := zshrcPath(); f != "" {
i = append(i, zsh{f})
}
if d := fishConfigDir(); d != "" {
Expand All @@ -74,6 +74,19 @@ func installers() (i []installer) {
return
}

// zshrcPath returns the path to the first .zshrc found following the
// same order of preference as zsh. (zsh will only look in HOME if ZDOTDIR is undefined)
func zshrcPath() string {
if zDotDir := os.Getenv("ZDOTDIR"); zDotDir != "" {
fp := filepath.Join(zDotDir, ".zshrc")
// Return early if fp exists and is not a directory
if info, err := os.Stat(fp); err == nil && !info.IsDir() {
return fp
}
}
return rcFile(".zshrc")
}

func fishConfigDir() string {
configDir := filepath.Join(getConfigHomePath(), "fish")
if configDir == "" {
Expand Down