From 64988efb09e5c9b102694b1ed8c3650df01e14e1 Mon Sep 17 00:00:00 2001 From: maxrantil Date: Mon, 17 Nov 2025 14:37:20 +0100 Subject: [PATCH 1/2] 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 --- .zprofile | 39 ++++++++++++++++++++------------------- .zshenv | 10 ++++++++++ 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/.zprofile b/.zprofile index f4e94c7..4266f42 100644 --- a/.zprofile +++ b/.zprofile @@ -1,19 +1,12 @@ +# shellcheck shell=bash # ABOUTME: Login shell configuration with XDG Base Directory and PATH setup # .zprofile - Runs once at login # Environment variables and PATH configuration -# Add ~/.local/bin to PATH (including subdirectories) -export PATH="$PATH:$HOME/.local/bin" +# NOTE: Essential variables (EDITOR, VISUAL, BROWSER, PATH, XDG_*) are now in .zshenv +# This ensures they're available in both login and non-login shells (e.g., SSH sessions) -# Default programs -export EDITOR="nvim" -export VISUAL="nvim" -export BROWSER="firefox" - -# XDG Base Directory specification -export XDG_CONFIG_HOME="$HOME/.config" -export XDG_DATA_HOME="$HOME/.local/share" -export XDG_CACHE_HOME="$HOME/.cache" +# Additional XDG Base Directory paths (less critical, can stay here) # Clean up home directory by setting XDG paths export LESSHISTFILE="-" @@ -34,19 +27,27 @@ export PASSWORD_STORE_DIR="${XDG_DATA_HOME}/password-store" # Less colors for man pages export LESS=-R -export LESS_TERMCAP_mb="$(printf '%b' '[1;31m')" -export LESS_TERMCAP_md="$(printf '%b' '[1;36m')" -export LESS_TERMCAP_me="$(printf '%b' '[0m')" -export LESS_TERMCAP_so="$(printf '%b' '[01;44;33m')" -export LESS_TERMCAP_se="$(printf '%b' '[0m')" -export LESS_TERMCAP_us="$(printf '%b' '[1;32m')" -export LESS_TERMCAP_ue="$(printf '%b' '[0m')" +LESS_TERMCAP_mb="$(printf '%b' '[1;31m')" +export LESS_TERMCAP_mb +LESS_TERMCAP_md="$(printf '%b' '[1;36m')" +export LESS_TERMCAP_md +LESS_TERMCAP_me="$(printf '%b' '[0m')" +export LESS_TERMCAP_me +LESS_TERMCAP_so="$(printf '%b' '[01;44;33m')" +export LESS_TERMCAP_so +LESS_TERMCAP_se="$(printf '%b' '[0m')" +export LESS_TERMCAP_se +LESS_TERMCAP_us="$(printf '%b' '[1;32m')" +export LESS_TERMCAP_us +LESS_TERMCAP_ue="$(printf '%b' '[0m')" +export LESS_TERMCAP_ue # FZF configuration export FZF_DEFAULT_OPTS="--layout=reverse --height 40%" # GPG fix -export GPG_TTY=$(tty) +GPG_TTY=$(tty) +export GPG_TTY # Fix locale export LANG=en_US.UTF-8 diff --git a/.zshenv b/.zshenv index f706b15..0c880cf 100644 --- a/.zshenv +++ b/.zshenv @@ -12,3 +12,13 @@ export XDG_CACHE_HOME="$HOME/.cache" # Set ZDOTDIR so zsh looks for .zshrc in the right place # This is critical for XDG compliance - without it, zsh looks for .zshrc in $HOME export ZDOTDIR="${XDG_CONFIG_HOME}/zsh" + +# Default programs (needed for aliases like v=$EDITOR, e=$EDITOR) +# Must be here (not .zprofile) so non-login shells have them +export EDITOR="nvim" +export VISUAL="nvim" +export BROWSER="firefox" + +# Add ~/.local/bin to PATH +# Required for non-login shells to find user scripts +export PATH="$HOME/.local/bin:$PATH" From f30f81de46fce9eb9c53e683235e575709996e27 Mon Sep 17 00:00:00 2001 From: Max Rantil Date: Mon, 17 Nov 2025 16:59:10 +0100 Subject: [PATCH 2/2] docs: update session handoff for Issue #115 fix --- SESSION_HANDOVER.md | 87 ++++++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 36 deletions(-) diff --git a/SESSION_HANDOVER.md b/SESSION_HANDOVER.md index fa2a433..9761440 100644 --- a/SESSION_HANDOVER.md +++ b/SESSION_HANDOVER.md @@ -1,64 +1,79 @@ -# Session Handoff: Dotfiles Fix for Issue maxrantil/vm-infra#114 +# Session Handoff: Dotfiles EDITOR/PATH Fix for Issue maxrantil/vm-infra#115 **Date**: 2025-11-17 -**Issue**: maxrantil/vm-infra#114 - Missing .zshenv causes dotfiles to fail in non-login shells -**PR**: maxrantil/dotfiles#72 -**Branch**: fix/issue-114-zshenv-missing +**Issue**: maxrantil/vm-infra#115 - Missing EDITOR/VISUAL/PATH in .zshenv breaks aliases +**PR**: maxrantil/dotfiles#73 +**Branch**: fix/issue-115-editor-path-zshenv ## ✅ Completed Work -### Root Cause Analysis -- Identified that `.zprofile` only runs for login shells, but SSH sessions are non-login -- Without `.zprofile`, `ZDOTDIR` was never set -- zsh looked for `.zshrc` in wrong location (`$HOME` instead of `~/.config/zsh/`) -- `generate-shortcuts.sh` created files with 664 permissions, rejected by `safe_source` +### Issue Discovery +- User reported `v` alias not working in VM SSH sessions +- Investigation revealed `EDITOR` variable was empty +- Root cause: PR #72 moved `ZDOTDIR` to `.zshenv` but missed `EDITOR`, `VISUAL`, `BROWSER`, and `PATH` ### Changes Implemented -1. **Created `.zshenv`**: Minimal file with XDG variables and ZDOTDIR (sourced for ALL shells) -2. **Updated `install.sh`**: Added symlinking of `.zshenv` to `$HOME/.zshenv` -3. **Fixed `generate-shortcuts.sh`**: Added `chmod 644` to ensure secure permissions on generated shortcutrc -4. **Fixed formatting**: Applied shfmt formatting to install.sh pragma comments +1. **Moved to `.zshenv`**: + - `EDITOR="nvim"` (needed for aliases like `v=$EDITOR`, `e=$EDITOR`) + - `VISUAL="nvim"` + - `BROWSER="firefox"` + - `PATH="$HOME/.local/bin:$PATH"` (needed to find user scripts) + +2. **Updated `.zprofile`**: + - Added shellcheck directive + - Fixed SC2155 warnings (separate declare/export for command substitutions) + - Added explanatory comment about variable locations + - Kept less critical variables (LESSHISTFILE, CARGO_HOME, GOPATH, etc.) ### Testing Results -✅ Tested in VM provisioned with `--test-dotfiles ~/workspace/dotfiles` -✅ All aliases functional: `cf`, `sc`, `h`, `doc` -✅ `ZDOTDIR` correctly set to `/home/mr/.config/zsh` in all shell types -✅ `shortcutrc` has correct permissions (644, not 664) -✅ All pre-commit hooks passing locally +✅ Verified in VM via SSH (non-login shell): +- `EDITOR=nvim` (set correctly) +- `v is an alias for nvim` (alias expands correctly) +- `e is an alias for nvim` (alias expands correctly) +- `v --version` opens nvim successfully +✅ All pre-commit hooks passing +✅ Shellcheck warnings fixed ✅ PR created and pushed to GitHub ## 🎯 Current Project State **Tests**: ✅ Manual testing complete in VM -**Branch**: fix/issue-114-zshenv-missing -**CI/CD**: 🔄 Running (PR #72) -**Commits**: 3 commits (pragma comments, main fix, formatting) +**Branch**: fix/issue-115-editor-path-zshenv +**CI/CD**: 🔄 Running (PR #73) +**Related Issues**: +- #115 - This fix (EDITOR/PATH missing) +- #114 - Original bug (ZDOTDIR missing) +- #72 - First fix (ZDOTDIR added) ## 📋 Next Session Priorities **Immediate Next Steps:** -1. Monitor CI/CD checks on PR #72 +1. Monitor CI/CD checks on PR #73 2. Merge PR once all checks pass -3. Test in fresh VM provision to verify fix works end-to-end -4. Close maxrantil/vm-infra#114 +3. Test in fresh VM or update existing VM +4. Close maxrantil/vm-infra#115 +5. Consider closing maxrantil/vm-infra#114 (fully resolved now) -**Future Considerations:** -- Consider adding automated tests for dotfiles installation -- Document zsh sourcing order in README for future reference +**Lessons Learned:** +- When adding `.zshenv`, must move ALL essential variables from `.zprofile` +- Essential = anything used in aliases or needed by non-login shells +- Test both login and non-login shells when making env variable changes ## 📝 Startup Prompt for Next Session -Read CLAUDE.md to understand our workflow, then verify dotfiles PR #72 CI status and merge if green. +Read CLAUDE.md to understand our workflow, then verify dotfiles PR #73 CI status and merge if green. -**Immediate priority**: Merge maxrantil/dotfiles#72 after CI passes -**Context**: Fixed missing .zshenv bug that broke aliases in non-login shells -**Reference docs**: maxrantil/vm-infra#114, SESSION_HANDOVER.md (this file) +**Immediate priority**: Merge maxrantil/dotfiles#73 after CI passes +**Context**: Fixed missing EDITOR/VISUAL/BROWSER/PATH that broke aliases in non-login shells +**Reference docs**: maxrantil/vm-infra#115, SESSION_HANDOVER.md (this file) **Ready state**: PR pushed, awaiting CI validation -**Expected scope**: Merge PR, verify in fresh VM, close issue #114 +**Expected scope**: Merge PR, verify aliases work in VM, close both issues #114 and #115 ## 📚 Key Reference Documents -- maxrantil/vm-infra#114 (bug report) -- maxrantil/dotfiles#72 (fix PR) -- `.zshenv` (new file with XDG/ZDOTDIR setup) -- `install.sh` (updated with .zshenv symlinking) +- maxrantil/vm-infra#115 (this bug - EDITOR/PATH missing) +- maxrantil/vm-infra#114 (original bug - ZDOTDIR missing) +- maxrantil/dotfiles#73 (this fix PR) +- maxrantil/dotfiles#72 (first fix PR - ZDOTDIR) +- `.zshenv` (now contains ALL essential variables) +- `.zprofile` (now only less critical variables)