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

Fix #6533 - Add support for zsh ZDOTDIR #6540

Merged
merged 3 commits into from Oct 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions Library/Homebrew/test/utils/shell_spec.rb
Expand Up @@ -19,8 +19,15 @@
expect(subject.profile).to eq("~/.bash_profile")
end

it "returns /tmp/.zshrc for Zsh if ZDOTDIR is /tmp" do
ENV["SHELL"] = "/bin/zsh"
ENV["ZDOTDIR"] = "/tmp"
expect(subject.profile).to eq("/tmp/.zshrc")
end

it "returns ~/.zshrc for Zsh" do
ENV["SHELL"] = "/bin/zsh"
ENV["ZDOTDIR"] = nil
MikeMcQuaid marked this conversation as resolved.
Show resolved Hide resolved
expect(subject.profile).to eq("~/.zshrc")
end

Expand Down
2 changes: 2 additions & 0 deletions Library/Homebrew/utils/shell.rb
Expand Up @@ -39,6 +39,8 @@ def export_value(key, value, shell = preferred)

# return the shell profile file based on user's preferred shell
def profile
return "#{ENV["ZDOTDIR"]}/.zshrc" if preferred == :zsh && ENV["ZDOTDIR"].present?

SHELL_PROFILE_MAP.fetch(preferred, "~/.bash_profile")
end

Expand Down