.bash_login文件未在新终端窗口中加载或在我关闭终端并重新打开它之后

时间:2012-09-26 21:35:02

标签: macos terminal

当我创建新的终端窗口或关闭终端并重新打开终端窗口时,我的.bash_login文件未加载。我必须跑:

source~ / .bash_login

每次为了使.bash_login中的别名都能正常工作。知道为什么吗?

2 个答案:

答案 0 :(得分:1)

每次登录时都会读取

./bash_login(重新启动计算机,重新启动桌面或连接到远程计算机等),并且创建新终端时没有登录。如果要在每次打开时加载别名新终端,您需要将它们放在/.bashrc中。

答案 1 :(得分:1)

你有〜/ .bash_profile文件吗?如果是这样,它将优先使用〜/ .bash_login。从bash手册页:

When  bash  is invoked as an interactive login shell, or as a non-
interactive shell with the --login option, it first reads and exe-
cutes  commands  from  the file /etc/profile, if that file exists.
After  reading  that   file,   it   looks   for   ~/.bash_profile,
~/.bash_login,  and  ~/.profile, in that order, and reads and exe-
cutes commands from the first one that  exists  and  is  readable.
The  --noprofile  option  may be used when the shell is started to
inhibit this behavior.