Merge pull request #6540 from davidosomething/support-zdotdir

Fix #6533 - Add support for zsh ZDOTDIR
This commit is contained in:
Mike McQuaid 2019-10-08 12:38:27 +01:00 committed by GitHub
commit 59e3cc7990
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -19,8 +19,15 @@ describe Utils::Shell do
expect(subject.profile).to eq("~/.bash_profile") expect(subject.profile).to eq("~/.bash_profile")
end 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 it "returns ~/.zshrc for Zsh" do
ENV["SHELL"] = "/bin/zsh" ENV["SHELL"] = "/bin/zsh"
ENV["ZDOTDIR"] = nil
expect(subject.profile).to eq("~/.zshrc") expect(subject.profile).to eq("~/.zshrc")
end end

View File

@ -39,6 +39,8 @@ module Utils
# return the shell profile file based on user's preferred shell # return the shell profile file based on user's preferred shell
def profile def profile
return "#{ENV["ZDOTDIR"]}/.zshrc" if preferred == :zsh && ENV["ZDOTDIR"].present?
SHELL_PROFILE_MAP.fetch(preferred, "~/.bash_profile") SHELL_PROFILE_MAP.fetch(preferred, "~/.bash_profile")
end end