Skip to content

Conversation

@maxrantil
Copy link
Owner

Summary

Fixes maxrantil/vm-infra#114

Adds .zshenv file to ensure dotfiles work in non-login shells (SSH, tmux, subshells).

Problem

  • Dotfiles failed to load in non-login shells
  • .zprofile only runs for login shells but sets critical ZDOTDIR
  • Without ZDOTDIR, zsh looks for .zshrc in wrong location ($HOME instead of ~/.config/zsh/)
  • shortcutrc had 664 permissions, rejected by safe_source security checks

Changes

  1. Added .zshenv: Minimal file with XDG variables and ZDOTDIR (sourced for ALL shells)
  2. Updated install.sh: Now symlinks .zshenv to $HOME/.zshenv
  3. Fixed generate-shortcuts.sh: Sets secure 644 permissions on generated shortcutrc

Testing

✅ Tested in VM provisioned with --test-dotfiles
✅ Aliases work in SSH sessions: cf, sc, h, doc all functional
ZDOTDIR correctly set to /home/mr/.config/zsh
shortcutrc has correct permissions (644, not 664)
✅ All pre-commit hooks passing

Impact

  • High priority: Core functionality restored for non-login shells
  • Scope: All VM provisioning with --test-dotfiles flag
  • Breaking changes: None (additive only)

Files Changed

  • .zshenv (new): XDG and ZDOTDIR setup for all shells
  • install.sh: Added .zshenv symlinking
  • generate-shortcuts.sh: Added chmod 644 for security compliance

Fixes #114

Problem:
- Dotfiles failed to load in non-login shells (SSH, tmux, subshells)
- .zprofile only runs for login shells, but sets critical ZDOTDIR
- Without ZDOTDIR, zsh looks for .zshrc in wrong location
- shortcutrc had 664 permissions, rejected by safe_source

Changes:
- Add .zshenv with XDG variables and ZDOTDIR (runs for ALL shells)
- Update install.sh to symlink .zshenv to $HOME/.zshenv
- Fix generate-shortcuts.sh to create shortcutrc with 644 permissions

Impact:
- Aliases and dotfiles now work in all shell types
- Maintains security with proper file permissions
@maxrantil maxrantil changed the title Fix: add .zshenv for non-login shell support fix: add .zshenv for non-login shell support Nov 17, 2025
@maxrantil maxrantil merged commit db82ae6 into master Nov 17, 2025
13 checks passed
maxrantil added a commit that referenced this pull request Nov 17, 2025
Fixes maxrantil/vm-infra#115

Problem:
- Aliases like 'v' and 'e' don't work in non-login shells (SSH)
- These aliases depend on $EDITOR being set
- EDITOR, VISUAL, BROWSER, and PATH were only in .zprofile
- .zprofile only runs for login shells

Changes:
- Move EDITOR, VISUAL, BROWSER to .zshenv (runs for ALL shells)
- Move PATH addition to .zshenv (needed for user scripts)
- Add shellcheck directive to .zprofile
- Fix SC2155 warnings in .zprofile (separate declare and assign)
- Update .zprofile with note explaining variable locations
- Keep less critical variables in .zprofile (LESSHISTFILE, etc.)

Impact:
- Aliases 'v', 'e' now work in SSH sessions
- User scripts in ~/.local/bin are found in all shells
- Completes the .zshenv fix started in #72
maxrantil added a commit that referenced this pull request Nov 17, 2025
Fixes maxrantil/vm-infra#115

Problem:
- Aliases like 'v' and 'e' don't work in non-login shells (SSH)
- These aliases depend on $EDITOR being set
- EDITOR, VISUAL, BROWSER, and PATH were only in .zprofile
- .zprofile only runs for login shells

Changes:
- Move EDITOR, VISUAL, BROWSER to .zshenv (runs for ALL shells)
- Move PATH addition to .zshenv (needed for user scripts)
- Add shellcheck directive to .zprofile
- Fix SC2155 warnings in .zprofile (separate declare and assign)
- Update .zprofile with note explaining variable locations
- Keep less critical variables in .zprofile (LESSHISTFILE, etc.)

Impact:
- Aliases 'v', 'e' now work in SSH sessions
- User scripts in ~/.local/bin are found in all shells
- Completes the .zshenv fix started in #72
maxrantil added a commit that referenced this pull request Nov 17, 2025
* fix: move EDITOR, VISUAL, BROWSER, and PATH to .zshenv

Fixes maxrantil/vm-infra#115

Problem:
- Aliases like 'v' and 'e' don't work in non-login shells (SSH)
- These aliases depend on $EDITOR being set
- EDITOR, VISUAL, BROWSER, and PATH were only in .zprofile
- .zprofile only runs for login shells

Changes:
- Move EDITOR, VISUAL, BROWSER to .zshenv (runs for ALL shells)
- Move PATH addition to .zshenv (needed for user scripts)
- Add shellcheck directive to .zprofile
- Fix SC2155 warnings in .zprofile (separate declare and assign)
- Update .zprofile with note explaining variable locations
- Keep less critical variables in .zprofile (LESSHISTFILE, etc.)

Impact:
- Aliases 'v', 'e' now work in SSH sessions
- User scripts in ~/.local/bin are found in all shells
- Completes the .zshenv fix started in #72

* docs: update session handoff for Issue #115 fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing .zshenv causes dotfiles to fail in non-login shells

2 participants