This write-up provides a straightforward strategy to incorporate automatic Node.js version control with the Fish shell, whilst avoiding resource-hungry frameworks like oh-my-fish which can often slow down the shell.
nvm, while built for Bash and Zsh shells, isn't directly compatible with the Fish shell. There are several ways to mesh nvm with the Fish shell, but they are often too intricate or resource-consuming.
In my experience, attempting to use an NVM clone in Fish shell fell short of my expectations. It failed to accomplish the primary task of automatically shifting between Node.js versions when I switch the directory based on the
The goal is to have Node.js versions switch automatically when the directory is changed, based on the
Why not use
.nvmrc file is favored due to its support for additional options like
lts/*, plus being a standard for nvm.
The implementation is uncomplicated as usual. It doesn't entail multiple dependencies or complex logic. It's essentially a few lines of code that get the job done.
fisher install edc/bass
I suggest using fisher as a simplistic plugin manager for Fish. I've authored a plugin that can be easily installed through fisher and amalgamated into any Fish environment. Should you have reasons not to use Fisher, simply copy-paste
nvm.fish files from all directories to your
~/.config/fish/ in their respective ones.
To set up the plugin with fisher, execute the following command:
fisher install aohorodnyk/fish-nvm
Upon changing the directory based on the
.nvmrc file, the plugin will automatically switch between Node.js versions. If the required version of Node.js isn't installed, it will be installed automatically.
No particular configurations are required for this plugin. However, you can configure it by setting the below environment variables:
yes): Toggles Fish NVM on or off. Set to
yes): Toggles on or off the announcement of the Node.js version change. Set to
Don't hesitate to utilize the Fish shell. It's a fast, versatile, and user-friendly shell that stands as a strong contender to bash and zsh.
Contributing to open-source is a great way to learn, assist others, and help make the technological world simpler and better for all.