我已经阅读了很多建议,而不是将您的自定义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文件。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。