Closed luhc228 closed 3 years ago
目前,安装 nvm 时会调用 shell 脚本 sh install.sh (install.sh 是来自于 https://github.com/nvm-sh/nvm)。假如现在同时存在 .bash_profile 和 .zshrc 时并且默认的 shell 是 /bin/zsh 时,会把 nvm 的配置写到 .bash_profile 中,但是期望的是 .zshrc。
sh install.sh
需要先获取当前的 shell,然后再去调用执行 install.sh
install.sh
function getShellName(): string { const shellPath = process.env.SHELL; const splitPaths = shellPath.split('/'); return splitPaths[splitPaths.length - 1]; } getShellName(); // zsh or sh or bash
背景
目前,安装 nvm 时会调用 shell 脚本
sh install.sh
(install.sh 是来自于 https://github.com/nvm-sh/nvm)。假如现在同时存在 .bash_profile 和 .zshrc 时并且默认的 shell 是 /bin/zsh 时,会把 nvm 的配置写到 .bash_profile 中,但是期望的是 .zshrc。解决
需要先获取当前的 shell,然后再去调用执行
install.sh