nvm-sh / nvm

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions
MIT License
80.01k stars 8.01k forks source link

Modifying a file when .bashrc and .zshrc are present #592

Open JJ opened 9 years ago

JJ commented 9 years ago

I just switched to zsh so still there's .bashrc and .zshrc present in my ~ . However, it's choosing .bashrc over the one I'm actually using, so I copied it by hand. I know it's a particular problem, but maybe the script could check the current shell and modify whatever file suits it?

ljharb commented 9 years ago

That sounds great in theory but I suspect it would be really complex in practice. I'll leave this open so anyone can contribute ideas - PRs welcome also :-)

jeanlucaslima commented 9 years ago

There's an environment variable called $SHELL that stores the default shell, even if you are running other shell at the moment.

echo-shell

ljharb commented 9 years ago

When installing nvm, I'd expect it to be installed in the current shell, not the default shell.

JJ commented 9 years ago

I'd go for $SHELL, then. At any rate, checking $SHELL instead of just installing it in whatever .*rc file you find first might be a better solution.

jeanlucaslima commented 9 years ago

@ljharb, if you want just for the current shell, you can use echo $0. But I'd vote for default shell.

ljharb commented 9 years ago

Certainly if we went with the default shell you'd be able to do SHELL=zsh . install.sh or SHELL=bash . install.sh to override it, so that's not a horrible idea.