600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > mac装机系列:每次打开iTerm都需要source bash_profile问题

mac装机系列:每次打开iTerm都需要source bash_profile问题

时间:2022-06-18 00:33:49

相关推荐

mac装机系列:每次打开iTerm都需要source bash_profile问题

问题

当我们在.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

配置好 nvm 的时候,执行 source .bash_profile 使得配置生效,但是新开一个终端tab就会发现 nvm命令找不到。

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

在苹果公司发布了macOS Catalina(10.15),macOS的默认终端从bash变成了zsh

解决

方式一:

将以上配置文件写入到~/.zshrc中,然后 source 一下就好了

方式二:

编辑~/.zshrc文件在最后增加一行:

source ~/.bash_profile

然后 source 一下 .zshrc 就好了

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。