Skip to content

Feat/multishell cleanup - #1590

Closed
jpee1420 wants to merge 5 commits into
Schniz:masterfrom
jpee1420:feat/multishell-cleanup
Closed

jpee1420 wants to merge 5 commits into
Schniz:masterfrom
jpee1420:feat/multishell-cleanup

Conversation

@jpee1420

@jpee1420 jpee1420 commented Sep 2, 2026

Copy link
Copy Markdown

Summary

Automatically cleans up multishell symlink directories when a shell tab or session exits.

Motivation

Currently, every fnm env invocation generates an isolated multishell symlink directory in the user's runtime directory (e.g. /run/user/1000/fnm_multishells/... or AppData/Local/fnm_multishells). These directories are never deleted and accumulate indefinitely until system reboot.

Changes

  1. Shell trait: Added cleanup_on_exit(&self, multishell_path: &Path) -> Option<String>.
  2. Exit Hooks:
    • Bash: trap __fnm_cleanup EXIT using an array accumulator so repeated evaluations in the same session (e.g. source ~/.bashrc) clean up all session directories.
    • Zsh: add-zsh-hook zshexit _fnm_cleanup (idiomatic, doesn't overwrite existing traps).
    • Fish: --on-event fish_exit.
    • PowerShell: Register-EngineEvent -SourceIdentifier PowerShell.Exiting.
  3. install.sh: Added idempotency guard (grep -q "fnm env") to prevent duplicate blocks if the installer is run more than once.
  4. Tests & Changeset:
    • Unit tests added across all shells (cargo test shell::).
    • E2E test added (e2e/multishell-cleanup.test.ts).
    • Changeset added.

@jpee1420
jpee1420 marked this pull request as ready for review September 5, 2026 06:04
@jpee1420 jpee1420 closed this Sep 5, 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