Skip to content

fix(envtools): load custom aliases and functions in tmux and nested shells - #575

Merged
aversini merged 1 commit into
mainfrom
fix_envtools_load_custom_aliases_and_functions_in_tmux_and_nested_shells
Jun 27, 2026
Merged

aversini merged 1 commit into
mainfrom
fix_envtools_load_custom_aliases_and_functions_in_tmux_and_nested_shells

Conversation

@aversini

Copy link
Copy Markdown
Collaborator

Problem

Envtools' custom aliases and functions were silently missing in tmux panes — and, by the same mechanism, in ssh sessions and plain sub-shells.

The "already loaded" guard at the top of load.sh tested the exported EVTLS_RUNTIME_DIR. Exported variables are inherited by child processes, but shell functions and aliases are not. So a fresh shell (tmux pane, etc.) saw the inherited env var, concluded Envtools was already loaded, and returned early — leaving none of the aliases/functions defined. This is the same issue the VSCODE_CLI/VSC_TERMINAL carve-out was patching for VSCode terminals.

Fix

Key the guard off EVTLS_LOADED, a plain non-exported sentinel set at the end of a successful load. A non-exported variable persists across re-sourcing within the same shell (so source ~/.zshrc still no-ops, no double banner) but is never inherited by child shells — matching the actual lifetime of the functions/aliases. Any new shell now re-loads cleanly, and the VSCode-specific carve-out is no longer needed.

Verification

  • Real tmux session (server seeded with inherited EVTLS_RUNTIME_DIR, pane sources the real ~/.zshrc): ll alias + reload function present. ✅
  • Before/after: committed code reproduces the bug (FAIL); fixed code passes. ✅
  • Same-shell re-source still no-ops; reload still bypasses the guard. ✅
  • shellcheck clean. ✅

🤖 Generated with Claude Code

…hells

Custom aliases and functions were silently missing in tmux panes (and ssh
sessions and plain sub-shells). The "already loaded" guard tested the
exported EVTLS_RUNTIME_DIR, which is inherited by child processes even though
shell functions and aliases are not — so a fresh shell wrongly skipped setup.

Key the guard off EVTLS_LOADED, a non-exported sentinel whose lifetime matches
the functions/aliases (persists across same-shell re-sourcing, never inherited
by children). This removes the need for the VSCode-specific carve-out.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mveq2CrwNUF1eW8CRezpjJ
@aversini
aversini merged commit 74f7dfb into main Jun 27, 2026
4 checks passed
@aversini
aversini deleted the fix_envtools_load_custom_aliases_and_functions_in_tmux_and_nested_shells branch June 27, 2026 14:48
@aversini aversini mentioned this pull request Jun 27, 2026
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.

1 participant