Skip to content

Add fnm shell integration, consolidated with nvm - #10

Merged
markosamuli merged 3 commits into
masterfrom
feature/fnm
Jul 24, 2026
Merged

Add fnm shell integration, consolidated with nvm#10
markosamuli merged 3 commits into
masterfrom
feature/fnm

Conversation

@markosamuli

@markosamuli markosamuli commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds fnm shell integration, consolidated with the existing nvm integration into a single node/ module (node/node.zsh / node/node.bash) so only one Node.js version manager is ever active in a shell: nvm is preferred when ~/.nvm exists, otherwise fnm is initialized
  • fnm puts its default install dir (~/.local/share/fnm) on PATH and evals fnm env --use-on-cd, so the active node version switches automatically on .node-version/.nvmrc/package.json
  • nvm's completion scripts move unchanged to node/completion.{zsh,bash} (kept as separate files because this repo's shell loader only sources completion.zsh/completion.bash after compinit/bashcompinit run — folding them into node.zsh would break nvm's completions)
  • Replaces the standalone nvm/ and fnm/ module directories

Why the change

Copilot's review flagged that the original fnm/ module loaded fnm unconditionally even when nvm was also installed, which could register two competing chpwd hooks / 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

  • Verified in a fresh zsh/bash process with only ~/.nvm present: nvm loads, fnm's env/PATH setup is skipped (FNM_DIR stays empty)
  • Verified in a fresh zsh/bash process with no ~/.nvm: fnm loads, FNM_DIR resolves, chpwd autoload hook registers in zsh

https://claude.ai/code/session_01BxpnHchkE91aVGaUVEjcez

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.zsh to prepend fnm’s default install directory to PATH and eval fnm env --use-on-cd for zsh.
  • Add fnm/fnm.bash to 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.

Comment thread fnm/fnm.zsh Outdated
Comment thread fnm/fnm.bash Outdated
@markosamuli markosamuli changed the title feat: add fnm shell integration feat: add fnm shell integration, consolidated with nvm Jul 24, 2026
@markosamuli
markosamuli requested a review from Copilot July 24, 2026 21:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 6 changed files in this pull request and generated 2 comments.

Comment thread node/node.zsh Outdated
Comment thread node/node.bash Outdated
markosamuli and others added 2 commits July 24, 2026 23:15
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
@markosamuli markosamuli changed the title feat: add fnm shell integration, consolidated with nvm Add fnm shell integration, consolidated with nvm Jul 24, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 6 changed files in this pull request and generated no new comments.

@markosamuli
markosamuli merged commit 998b72d into master Jul 24, 2026
1 check passed
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.

2 participants