加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

osx – 如何使OS X读取.bash_profile不是.profile文件

发布时间:2020-12-15 19:57:48 所属栏目:安全 来源:网络整理
导读:我已经阅读了很多建议,而不是将您的自定义aka命令放在“.profile”文件中。相反,为自己创建一个.bash_profile,并添加别名等 但是,当我打开新终端时,如果只有.bash_profile,OS X不会导出/提供其中提到的命令。我必须手动输出.bash_profile。 如果我创建
我已经阅读了很多建议,而不是将您的自定义aka命令放在“.profile”文件中。相反,为自己创建一个.bash_profile,并添加别名等

但是,当我打开新终端时,如果只有.bash_profile,OS X不会导出/提供其中提到的命令。我必须手动输出.bash_profile。

如果我创建.profile文件,打开一个新的终端,我的所有命令在.profile中都将被执行,并且可以很容易地使用。

你能帮助我理解,它是如何工作的?此外,何时使用.bashrc / .profile / .bash_profile文件。

谢谢!

根据OS X附带的手册页:

… it looks for ~/.bash_profile,~/.bash_login,and ~/.profile,in that order,and reads and executes 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.

如果?/ .bash_profile和?/ .bash_login都不可读,应该只读?/ .profile作为最后的手段。

在我所有的OS X系统上,我的?/ .bash_profile设置为:

if [ -f ~/.bashrc ]; then
    source ~/.bashrc
fi

强烈建议您在OS X上执行此操作,以便按照您期望的方式获取bash以读取您的?/ .bashrc文件。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读