How to get Fish shell and NVM both installed with Homebrew to work together?
If you're using oh my fish you can install the nvm plugin (after installing NVM with homebrew).
$ omf install nvm
Then set the NVM_DIR and all should be fine.
$ set -gx NVM_DIR (brew --prefix nvm)
You can use Bass. Clone the git repository
git clone https://github.com/edc/bass.git
Then cd in the cloned directory and type
make install
bass source ~/.nvm/nvm.sh ';' nvm use stable
Now you should be able to use node inside fish shell.
I've created the following function inside ~/.config/fish/functions/nvm.fish
:
function _nvm
bass source (brew --prefix nvm)/nvm.sh --no-use ';' nvm $argv
end
function nvm
if test -e $NVM_CURRENT
echo Setting up nvm..
_nvm use default --silent
set -x -g NVM_CURRENT (_nvm current)
printf "Using Node %s\n" $NVM_CURRENT
end
_nvm $argv
end
After having several issues with other plugins, this just works.