mac电脑系统版本10.15.5

在.bash_profile文件中写入下面内容

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

执行 source .bash_profile文件

之后nvm可以正常允许,但是新开一个终端tab就会发现 nvm命令找不到,找了很多资料终于解决了。

这是因为新的mac系统默认终端是zsh不再是bash,默认启动的文件是.zshrc不是.bash_profile。所以这样配置不会一直生效。

touch .zshrc

vim .zshrc

将上面文件那天复制搭配.zshrc文件中

source .zshrc文件

问题得到解决

这就意味着,.bashrc文件和.bash_profile文件不需要了

说一下环境变量的作用

环境变量文件的优先级

/etc/profile /etc/paths ~/.bash_profile ~/.bash_login ~/.profile ~/.bashrc
  • /etc/profile (建议不修改这个文件 ) 全局(公有)配置,不管是哪个用户,登录时都会读取该文件。
  • /etc/bashrc (一般在这个文件中添加系统级环境变量) 全局(公有)配置,bash shell执行时,不管是何种方式,都会读取此文件。
  • ~/.bash_profile (一般在这个文件中添加用户级环境变量) 每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该文件仅仅执行一次!
  • ~/.bashrc (一般在这个文件中添加用户级环境变量) bash shell执行时,不管是何种方式,都会读取此文件。

 如果你的终端不是bash是zsh,配置文件就会是.zshrc。

这里使用的是.zshrc 类似.bashrc ,终端打开就会执行

GitHub 加速计划 / term / terminal
94.53 K
8.17 K
下载
The new Windows Terminal and the original Windows console host, all in the same place!
最近提交(Master分支:1 个月前 )
494bc5bd Closes #17505 4 天前
36f064cf The settings UI and settings model allow you to set the icon to "none" to hide the icon (you can actually see this effect in the settings UI when changing the value of the profile icon). However, during settings validation, "none" is considered a file path, which is then failed to be parsed, resulting in the icon being marked as invalid and immediately clearing the value. This PR fixes this issue by considering "none" to be an accepted value during validation. Related to #15843 Closes #17943 ## Validation Steps Performed When an icon is set to "none", ... ✅ no more warning ✅ the icon is hidden 4 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐