Support for zsh ZDOTDIR, FIX #6533

- Add test spec with ZDOTDIR set and unset
This commit is contained in:
David O'Trakoun 2019-10-06 12:03:01 -04:00
parent fd9a09e18f
commit 960b8b659c
No known key found for this signature in database
GPG Key ID: 990485D795ECA828
2 changed files with 8 additions and 0 deletions

View File

@ -19,8 +19,15 @@ describe Utils::Shell do
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
expect(subject.profile).to eq("~/.zshrc")
end

View File

@ -39,6 +39,7 @@ module Utils
# return the shell profile file based on user's preferred shell
def profile
return ENV.fetch("ZDOTDIR", "~") + "/.zshrc" if preferred.eql? "zsh"
SHELL_PROFILE_MAP.fetch(preferred, "~/.bash_profile")
end