如果.bash_profile通常以任何方式提供.bashrc,为什么不使用.bashrc呢?

nop*_*ole 11 bash .bash-profile

看来我们会放

source ~/.bashrc
Run Code Online (Sandbox Code Playgroud)

无论如何,在我们的.bash_profile中.那么为什么不使用一个文件,比如说.bashrc?

Ale*_*lli 18

因为每次登录时你可能只想做一次(所以.bash_profile),而不是每次打开xterm等(按照.bashrc),例如要求用户输入密码以解密并将SSH密钥加载到ssh代理中等等


180*_*ION 6

你可以放一些.bash_profile不适合不是终端的shell实例的东西.例如,如果您通过shell从编辑器运行外部命令 - shell实例将提供.bashrc但不是.bash_profile.例如,我可能会放入alias ls=ls -F我的配置文件,但您不希望将该别名仅应用于shell的任何实例,只需要与之交互的实例.