Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look for .zshrc in ZDOTDIR if defined #71

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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 {
posener marked this conversation as resolved.
Show resolved Hide resolved
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