fix: ZDOTDIR and XDG_CONFIG_HOME config detecting (#51)

From this discussion:

https://www.reddit.com/r/zsh/comments/1v8rq7s/comment/p09b05o/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button

---

Problem: Iris hardcodes config paths to `~/.zshrc` and
`~/.config/fish/config.fish`. This ignores users' custom `ZDOTDIR` or
`XDG_CONFIG_HOME` setups, polluting their `$HOME` directory during init
and failing to scan their actual aliases. Also, ZDOTDIR is often set in
`~/.zshenv` without export, making it invisible to Go's `os.Getenv`

Solution:
- Bash: default `$HOME/.bashrc` so dont mind about it
- For Zsh, Iris now probes zsh directly (`zsh -c "echo $ZDOTDIR"`) with
a timeout to accurately resolve custom paths even if they aint exported
- For Fish, Iris now natively respects the `XDG_CONFIG_HOME` environment
variable
- Shared this robust resolution logic across init, uninstall, and alias
scanning
- Fixed alias scanning to process files in the correct zsh startup order
(`.zshenv` -> `.zprofile` -> `.zshrc`) and correctly merge them
This commit is contained in:
VERSE
2026-07-28 21:46:34 +07:00
committed by GitHub
parent 6f488c02cd
commit ebb0bead7d
3 changed files with 57 additions and 6 deletions
+5 -2
View File
@@ -8,6 +8,7 @@ import (
"strings"
"github.com/spf13/cobra"
"github.com/versenilvis/iris/integration/shell"
"github.com/versenilvis/iris/internal/config"
)
@@ -26,10 +27,12 @@ var uninstallCmd = &cobra.Command{
return
}
zshrcPath := filepath.Join(shell.GetZshConfigDir(), ".zshrc")
configFiles := []string{
filepath.Join(home, ".zshrc"),
zshrcPath,
filepath.Join(home, ".bashrc"),
filepath.Join(home, ".config", "fish", "config.fish"),
filepath.Join(shell.GetFishConfigDir(), "config.fish"),
}
for _, file := range configFiles {