代码之家  ›  专栏  ›  技术社区  ›  Matthew Rankin val

在中打开BASH shell时如何设置PATH env变量终端.app在OSX上?

  •  3
  • Matthew Rankin val  · 技术社区  · 14 年前

    什么启动脚本按它们被称为的顺序设置 PATH 在中打开BASH shell时的变量终端.app在OSX上?

    1 回复  |  直到 14 年前
        1
  •  7
  •   Matthew Rankin    14 年前

    /usr/libexec/path_helper 在档案里找到的 /etc/paths 在目录里 /etc/paths.d/

    弗斯特 bash /etc/profile 执行以下代码:

    if [ -x /usr/libexec/path_helper ]; then
        eval `/usr/libexec/path_helper -s`
        # The above line is the secret sauce, so to say...
        # First is adds default PATH values from the file /etc/paths
        # Then all files in the /etc/paths.d/ directory are read and directories listed
        # in each file (one per line) are appended to PATH
    fi
    
    if [ "${BASH-no}" != "no" ]; then
        [ -r /etc/bashrc ] && . /etc/bashrc
    fi
    

    猛击 寻找 ~/.bash_profile , ~/.bash_login ~/.profile .

    PATH 其结构如下:

    1. 文件中的目录 路径
    2. 目录中列出的文件在目录中 /etc/路径.d/ 附加 路径 请注意,这些是附加的,而不是前置的。
    3. 各种各样的 PATH={DIR_2_ADD}:"${PATH}" 我的声明 ~/.bash\u配置文件 ~/.bashrc 文件已预处理