Skip to content

Conversation

@maxrantil
Copy link
Owner

Summary

Fixes maxrantil/vm-infra#115

Moves essential environment variables from .zprofile to .zshenv so aliases work in non-login shells (SSH sessions).

Problem

Issue #72 fixed ZDOTDIR but missed other critical environment variables:

  • v alias doesn't work (expands to empty string)
  • e alias doesn't work (expands to empty string)
  • User scripts in ~/.local/bin aren't found

Root cause: These variables were only in .zprofile (login shells only):

export EDITOR="nvim"    # Used by aliases: v=$EDITOR, e=$EDITOR
export VISUAL="nvim"
export BROWSER="firefox"
export PATH="$HOME/.local/bin:$PATH"

Since SSH sessions are non-login shells, these variables were never set.

Changes

  1. Moved to .zshenv (runs for ALL shells):

    • EDITOR, VISUAL, BROWSER (needed for aliases)
    • PATH addition (needed to find user scripts)
  2. Updated .zprofile:

    • Added shellcheck directive
    • Fixed SC2155 warnings (separate declare and assign)
    • Added explanatory comment about variable locations
    • Kept less critical variables here (LESSHISTFILE, CARGO_HOME, etc.)

Testing

✅ Tested in VM with non-login shell (SSH):

ssh vm "zsh -c 'echo EDITOR=\$EDITOR'"  # EDITOR=nvim ✅
ssh vm "zsh -i -c 'type v'"             # v is an alias for nvim ✅
ssh vm "zsh -i -c 'type e'"             # e is an alias for nvim ✅
ssh vm "zsh -i -c 'v --version'"        # Opens nvim successfully ✅

✅ All pre-commit hooks passing
✅ Shellcheck warnings fixed

Impact

Related

@maxrantil maxrantil force-pushed the fix/issue-115-editor-path-zshenv branch from e14f92b to f30f81d Compare November 17, 2025 16:06
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 maxrantil merged commit 26e7e5a into master Nov 17, 2025
13 checks passed
@maxrantil maxrantil deleted the fix/issue-115-editor-path-zshenv branch November 17, 2025 16:10
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 EDITOR/VISUAL/PATH in .zshenv breaks aliases in non-login shells

2 participants