在 Fedora 28 上自动启用 bash 完成

Automatically enabling bash completion on Fedora 28

我有一个 Fedora 28 安装,我在上面安装了 bash bash-完成包。

我有运行以下:

source /etc/profile.d/bash_completion.sh

并且 bash 完成按预期工作。

但是,每当我重新登录时,我必须 运行 在 bash 完成开始工作之前执行上述命令 - 它不会自动启用。

我检查了bash_completion.sh文件的权限,甚至添加了x标志,但仍然没有自动启用。

我怎样才能让它工作?

setup 包提供的/etc/bashrc 文件,默认会获取/etc/profile.d/ 中的所有脚本。此外,默认情况下,您的 ~/.bashrc 应该具有以下内容(您可以通过查看 /etc/skel/.bashrc 来验证它是默认值):

# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

这是我在系统 (Fedora 28 Workstation) 上看到的该文件的相关部分(接近尾声):

for i in /etc/profile.d/*.sh; do
    if [ -r "$i" ]; then
        if [ "$PS1" ]; then
            . "$i"
        else
            . "$i" >/dev/null
        fi
    fi
done

这是我正在使用的 setup 版本(并证明这是它的来源):

$ rpm -q --whatprovides /etc/bashrc 
setup-2.11.4-1.fc28.noarch