Add fnm shell integration, consolidated with nvm - #10
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds fnm shell integration modules to this dotfiles repo so interactive zsh/bash sessions can auto-initialize fnm and enable directory-aware Node version switching.
Changes:
- Add
fnm/fnm.zshto prepend fnm’s default install directory toPATHandevalfnm env --use-on-cdfor zsh. - Add
fnm/fnm.bashto do the equivalent initialization for bash.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| fnm/fnm.zsh | Adds zsh module to put ~/.local/share/fnm on PATH and initialize fnm env --use-on-cd. |
| fnm/fnm.bash | Adds bash module to put ~/.local/share/fnm on PATH and initialize fnm env --use-on-cd. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Adds fnm/fnm.zsh and fnm/fnm.bash following the existing nvm/tfenv module pattern, auto-loaded via the dotfiles glob loader. Puts the default install dir on PATH and evals `fnm env --use-on-cd` so node version switches automatically on .node-version/.nvmrc/package.json. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BxpnHchkE91aVGaUVEjcez
Addresses Copilot review feedback: loading fnm's env unconditionally
alongside nvm could leave two Node version managers registering
competing chpwd hooks / PATH entries in the same shell.
node/node.zsh and node/node.bash now own the manager-selection logic
in one place: nvm is preferred when ~/.nvm exists, otherwise fnm is
initialized. This replaces the separate nvm/ and fnm/ modules.
nvm's completion scripts move to node/completion.{zsh,bash} unchanged
(kept separate from node.zsh/node.bash because this repo's loader
sources completion.zsh only after zsh's compinit/bashcompinit run,
so folding them into node.zsh would break nvm's completions).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BxpnHchkE91aVGaUVEjcez
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fnmshell integration, consolidated with the existingnvmintegration into a singlenode/module (node/node.zsh/node/node.bash) so only one Node.js version manager is ever active in a shell: nvm is preferred when~/.nvmexists, otherwise fnm is initializedfnmputs its default install dir (~/.local/share/fnm) onPATHand evalsfnm env --use-on-cd, so the active node version switches automatically on.node-version/.nvmrc/package.jsonnvm's completion scripts move unchanged tonode/completion.{zsh,bash}(kept as separate files because this repo's shell loader only sourcescompletion.zsh/completion.bashaftercompinit/bashcompinitrun — folding them intonode.zshwould break nvm's completions)nvm/andfnm/module directoriesWhy the change
Copilot's review flagged that the original
fnm/module loaded fnm unconditionally even whennvmwas also installed, which could register two competingchpwdhooks / PATH setups in the same shell. Consolidating manager selection into one file fixes that and makes it a single place to reason about which Node version manager is active.Test plan
zsh/bashprocess with only~/.nvmpresent: nvm loads, fnm's env/PATH setup is skipped (FNM_DIRstays empty)zsh/bashprocess with no~/.nvm: fnm loads,FNM_DIRresolves,chpwdautoload hook registers in zshhttps://claude.ai/code/session_01BxpnHchkE91aVGaUVEjcez