@@ -32,7 +32,7 @@ var initCmd = &cobra.Command{
3232
3333Automatically detects your shell and updates the appropriate config file:
3434 - bash: ~/.bashrc
35- - zsh: ~/.zshrc
35+ - zsh: ~/.zshrc (or $ZDOTDIR/.zshrc if ZDOTDIR is set)
3636 - powershell: $PROFILE (Windows only)
3737
3838The configuration is wrapped in markers so it can be safely updated or removed.
@@ -135,6 +135,14 @@ func getShellConfigPath(shell string) string {
135135 }
136136 return bashrc
137137 case "zsh" :
138+ // Respect ZDOTDIR if set: zsh reads its startup files from $ZDOTDIR (default: $HOME).
139+ // This avoids writing to the wrong (potentially unused or broken) ~/.zshrc.
140+ if zdotdir := strings .TrimSpace (os .Getenv ("ZDOTDIR" )); zdotdir != "" {
141+ if ! filepath .IsAbs (zdotdir ) {
142+ zdotdir = filepath .Join (home , zdotdir )
143+ }
144+ return filepath .Join (filepath .Clean (zdotdir ), ".zshrc" )
145+ }
138146 return filepath .Join (home , ".zshrc" )
139147 case "powershell" :
140148 // Check $PROFILE env var first (works for both Windows PowerShell 5.1 and PowerShell Core)
@@ -258,9 +266,9 @@ func installShellConfig(configPath, shell string, dryRun, noPrompt bool) error {
258266 fmt .Println ("To activate, run:" )
259267 switch shell {
260268 case "bash" :
261- fmt .Println (" source ~/.bashrc" )
269+ fmt .Printf (" source %s \n " , configPath )
262270 case "zsh" :
263- fmt .Println (" source ~/.zshrc" )
271+ fmt .Printf (" source %s \n " , configPath )
264272 case "powershell" :
265273 fmt .Println (" . $PROFILE" )
266274 }
0 commit comments