如何使OS X阅读的.bash_profile不.profile文件 [英] How to make OS X to read .bash_profile not .profile file

查看:175
本文介绍了如何使OS X阅读的.bash_profile不.profile文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看了一下,没有把您的自定义命令,又名中的.profile文件,所以很多建议。相反,创建一个.bash_profile中为自己添加您的别名等。

I have read so many suggestions about, not putting your customization aka commands in ".profile" file. Rather, create a .bash_profile for yourself and add your alias and etc.

但是,当我打开新的终端,如果只有.bash_profile中,OS X没有出口/采购在它提到的命令。我必须手动源.bash_profile文件。

But,when I open the new terminal, if there is only .bash_profile, OS X is not exporting/sourcing the commands mentioned in it. I have to manually source the .bash_profile.

如果我创建.profile文件,在打开一个新的终端,我在所有的.profile文件命令的执行,并将于容易。

If I create .profile file, on opening a new terminal, all my commands in .profile are executed and will be available readily.

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

Could you please help me in understanding, how does it works? Also, when to use .bashrc/.profile/.bash_profile files.

谢谢!

推荐答案

根据手册页附带OS X:

According to the manual page that ships with OS X:

...它看起来对于 〜/ .bash_profile中 〜/ .bash_login文件 〜/ .profile文件 ,按照这个顺序,并读取和存在的第一个执行命令并且可读。在 - NOPROFILE 当shell启动抑制这种行为可能被使用的选项。

... 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.

它应该只读〜/ .profile文件作为最后的手段,如果没有〜/ .bash_profile中也不〜/ .bash_login文件是可读。

It should only read ~/.profile as a last resort if neither ~/.bash_profile nor ~/.bash_login are readable.

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

On all of my OS X systems, I have my ~/.bash_profile set to:

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

强烈建议您为了得到bash的阅读做到这一点在OS X上的〜/ .bashrc中文件中像你期望的那样。

It is highly recommended that you do this on OS X in order to get bash to read your ~/.bashrc file like you would expect.

这篇关于如何使OS X阅读的.bash_profile不.profile文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆