Anaconda安装在Mac OS X上修改.bash_profile

问题描述:

我在Mac(Mojave)上安装了Anaconda,现在每当启动外壳程序时,它将自动激活conda环境.直到我意识到.bashrc中的某些命令在启动时未执行之前,这完全没问题.特别是,我增加了HISTSIZE和HISTFILESIZE,但是它们似乎始终停留在默认值500上.经过一番谷歌搜索后,我了解到由于安装了anaconda,启动时使用的是.bash_profile而不是.bashrc.这就是我的.bash_profile的外观(如下所示),只是将我的.bashrc文件(例如HISTFILESIZE = 100000)中的命令添加到我的.bash_profile的顶部似乎没有任何作用.关于我在做什么错的任何建议吗?谢谢!

I installed Anaconda on my Mac (Mojave) and now whenever I start a shell it automatically activates the conda environment. This was totally fine until I realized some of the commands in my .bashrc were not being executed on startup. In particular, I had increased HISTSIZE and HISTFILESIZE but they always seemed to be stuck at their default values of 500. After some googling, I learnt that because of my anaconda installation, it was my .bash_profile that was being used on startup and not .bashrc. This is what my .bash_profile looks like (see below), just adding commands from my .bashrc file (e.g., HISTFILESIZE=100000) to the top of my .bash_profile appears to do nothing. Any suggestions on what I am doing wrong? Thanks!

# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH
# added by Anaconda3 2019.07 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/anaconda3/etc/profile.d/conda.sh" ]; then
# . "/anaconda3/etc/profile.d/conda.sh"  # commented out by conda initialize
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda init <<<

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('//anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "//anaconda3/etc/profile.d/conda.sh" ]; then
        . "//anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="//anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

您可以尝试按照建议

You can try to add the following lines in the bash_profile as suggested Here:

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