终端 shell 中的别名问题

1 macos bash shell terminal alias

我在终端(macos)中将/bin/bash设置为默认 shell,而用“~/.bashrc”编写的别名不起作用(找不到命令)。

但如果我在终端/bin/bash命令中写入,我将切换到新的bash3.2 shell,然后我就可以使用它了。

是否还有另一个“.bashrc”,我应该在其中写下我的别名?

PS 我也使用终端首选项将/bin/bash设置为默认值和chsh -s /bin/bash/命令。

che*_*ner 5

Terminal启动登录 shell 而不是“普通”交互式 shell,因为终端本身不是从从登录 shell 继承环境的 shell 运行的。

普通交互式shell源码.bashrc;登录 shell 获取第一个.profile, .bash_login, 或.bash_profile它找到的内容。我建议.bashrc直接从采购.bash_profile

当您/bin/bash直接运行时,您的别名会起作用,因为这不会启动另一个登录 shell,因此.bashrc会按预期获取。