Respect ZDOTDIR environment variable iff set (#49913)

When `ZDOTDIR` is set, `zsh` reads its configuration from that directory
instead of the user’s `$HOME` directory.

| Setup | `ZDOTDIR` set? | Script writes to | Zsh reads from | Match? |
|---|---|---|---|---|
| XDG + `ZDOTDIR` | ✅ | `$ZDOTDIR/.zshrc` | `$ZDOTDIR/.zshrc` | ✅ |
| XDG without `ZDOTDIR` | ❌ | `$HOME/.zshrc` | `$HOME/.zshrc` | ✅ |
| No XDG at all | ❌ | `$HOME/.zshrc` | `$HOME/.zshrc` | ✅ |


Ref: https://zsh.sourceforge.io/Intro/intro_3.html

Release Notes:

- N/A
This commit is contained in:
Kunall Banerjee authored and GitHub committed 2026-02-23 18:04:16 +00:00
1 parent e128e1eade
commit 00250b90c6
1 file changed
+1 -1
+1 -1
View File
@@ -53,7 +53,7 @@ function getShellConfigPath(shell) {
const home = os.homedir();
switch (shell) {
case "zsh":
return path.join(home, ".zshrc");
return path.join(process.env.ZDOTDIR || home, ".zshrc");
case "bash":
// Prefer .bashrc, fall back to .bash_profile
const bashrc = path.join(home, ".bashrc");