mac ~/.bash_profile 重启失效

简介: mac ~/.bash_profile 重启失效

每次打开终端都需要source .bash_profile才能使用自己定义的环境变量

原因:以前默认shell是 /bin/bash ,而新版本的macOS Catalina开始,新用户的默认shell改为了 zsh。先加载 ~/.zshrc后就不加载了

解决:在~/.zshrc文件最后,增加一行: source ~/.bash_profile

  • 查看默认shell:echo $SHELL
  • 查看系统安装了哪些shell:cat /etc/shells
  • bash与zsh之间相互切换
# 切换bash
chsh -s /bin/bash
# 切换zsh
chsh -s /bin/zsh
  • 配置文件
  • bash读取的配置文件 open -e ~/.bash_profile
  • zsh读取的配置文件 open -e ~/.zshrc

当从bash切换为zsh时,如果不想重新配置一遍.zshrc文件,可以在.zshrc文件中加上source ~/.bash_profile,从而直接从.bash_profile文件读取配置


相关文章
|
2天前
|
Linux Shell
mac/linux提示bash: telnet: command not found
mac/linux提示bash: telnet: command not found
|
2天前
|
Linux Shell
mac/linux执行受限:bash: ./install.sh: Permission denied
mac/linux执行受限:bash: ./install.sh: Permission denied
|
2天前
|
Java Shell Linux
[醉了]解决重启mac但是bash_profile不生效的彻底解决方法
[醉了]解决重启mac但是bash_profile不生效的彻底解决方法
90 0
mac 安装软件后重启终端,刚才安装的命令都提示找不到
mac 安装软件后重启终端,刚才安装的命令都提示找不到
|
Shell 开发工具
mac添加bash_profile环境变量
mac添加bash_profile环境变量
172 0
|
Shell
MAC修改.bashrc/.bash_profile无效,默认的用户配置文件是.zshrc,
MAC修改.bashrc/.bash_profile无效,默认的用户配置文件是.zshrc,
245 0
|
Shell
【技术分享】Mac终端bash和zsh切换
【技术分享】Mac终端bash和zsh切换
238 0
|
关系型数据库 MySQL Shell
linux/mac 环境查看mysql版本时出现 :-bash: mysql: command not found
linux/mac 环境查看mysql版本时出现 :-bash: mysql: command not found
172 0
|
关系型数据库 MySQL
mac下启动/停止/重启mysql服务
mac下启动/停止/重启mysql服务
181 0
|
Shell
MAC修改.bashrc/.bash_profile无效,默认的用户配置文件是.zshrc,
MAC修改.bashrc/.bash_profile无效,默认的用户配置文件是.zshrc,
188 0