主目录中的.bashrc是否应该自动加载



我在.bashrc文件中添加了scala,但当我关闭mac并重新打开它时,它找不到它

source ~/.bashrc 

一切恢复正常。我想说,问题是整个文件,但问题是,我在那里有其他东西,以前工作得很好,但scala的问题一直存在。有人知道为什么会这样,并解释为什么我会遇到这个问题吗?这是我的.bashrc文件中的内容,它正确运行rvm和mysql,但不运行scala:

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
export PATH="/usr/local/mysql/bin:$PATH"
export PATH="/Users/Zeroe/scala-2.9.1-1/bin:$PATH"

我通过将echo "${BASH_SOURCE[0]}"添加到这些脚本中,得出了这个图。

                     +-----------------+   +------FIRST-------+   +-----------------+
                     |                 |   | ~/.bash_profile  |   |                 |
login shell -------->|  /etc/profile   |-->| ~/.bash_login ------>|  ~/.bashrc      |
                     |                 |   | ~/.profile       |   |                 |
                     +-----------------+   +------------------+   +-----------------+
                     +-----------------+   +-----------------+
                     |                 |   |                 |
interactive shell -->|  ~/.bashrc -------->| /etc/bashrc     |
                     |                 |   |                 |
                     +-----------------+   +-----------------+
                     +-----------------+
                     |                 |
logout shell ------->|  ~/.bash_logout |
                     |                 |
                     +-----------------+

注意

  1. []-->[]表示source by workflow(自动)
  2. [--->[]表示source by convention(手动。如果不手动,则不会发生任何事情。)
  3. FIRST表示find the first available, ignore rest

您的shell可能是一个登录shell,在这种情况下,bash将按顺序读取各种配置文件:

  1. /etc/profile
  2. ~/.bash_profile
  3. ~/.bash_login
  4. ~/.profile

通常从其中一个文件中获取~/.bashrc,这样您也可以获得相同的登录shell配置。

这就是我的~/.profile包含的内容:

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
    fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi
export LANGUAGE="en_US:en"
export LC_MESSAGES="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
export LC_COLLATE="en_US.UTF-8"

最新更新