@@ -152,7 +152,11 @@ func initShellBinaryFields(path string) *DevboxShell {
152
152
shell .userShellrcPath = rcfilePath (".bashrc" )
153
153
case "zsh" :
154
154
shell .name = shZsh
155
- shell .userShellrcPath = rcfilePath (".zshrc" )
155
+ if zdotdir := os .Getenv ("ZDOTDIR" ); zdotdir != "" {
156
+ shell .userShellrcPath = filepath .Join (os .ExpandEnv (zdotdir ), ".zshrc" )
157
+ } else {
158
+ shell .userShellrcPath = rcfilePath (".zshrc" )
159
+ }
156
160
case "ksh" :
157
161
shell .name = shKsh
158
162
shell .userShellrcPath = rcfilePath (".kshrc" )
@@ -357,14 +361,15 @@ func (s *DevboxShell) writeDevboxShellrc() (path string, err error) {
357
361
func (s * DevboxShell ) linkShellStartupFiles (shellSettingsDir string ) {
358
362
// For now, we only need to do this for zsh shell
359
363
if s .name == shZsh {
360
- // Useful explanation of zsh startup files: https://zsh.sourceforge.io/FAQ/zshfaq03 .html#l20
361
- filenames := []string {".zshenv" , ".zprofile" , ".zlogin" }
364
+ // List of zsh startup files: https://zsh.sourceforge.io/Intro/intro_3 .html
365
+ filenames := []string {".zshenv" , ".zprofile" , ".zlogin" , ".zlogout" }
362
366
363
367
// zim framework
364
368
// https://zimfw.sh/docs/install/
365
369
filenames = append (filenames , ".zimrc" )
366
370
367
371
for _ , filename := range filenames {
372
+ // The userShellrcPath should be set to ZDOTDIR already.
368
373
fileOld := filepath .Join (filepath .Dir (s .userShellrcPath ), filename )
369
374
_ , err := os .Stat (fileOld )
370
375
if errors .Is (err , fs .ErrNotExist ) {
@@ -376,12 +381,11 @@ func (s *DevboxShell) linkShellStartupFiles(shellSettingsDir string) {
376
381
}
377
382
378
383
fileNew := filepath .Join (shellSettingsDir , filename )
379
-
380
- if err := os .Link (fileOld , fileNew ); err == nil {
381
- debug .Log ("Linked shell startup file %s to %s" , fileOld , fileNew )
382
- } else {
384
+ cmd := exec .Command ("cp" , fileOld , fileNew )
385
+ if err := cmd .Run (); err != nil {
383
386
// This is a best-effort operation. If there's an error then log it for visibility but continue.
384
- debug .Log ("Error linking zsh setting file from %s to %s: %v" , fileOld , fileNew , err )
387
+ debug .Log ("Error copying zsh setting file from %s to %s: %v" , fileOld , fileNew , err )
388
+ continue
385
389
}
386
390
}
387
391
}
0 commit comments