Automatically enabling bash completion on Fedora 28

Viewed 440

I have a Fedora 28 installation on which I have installed the bash bash-completion package.

I have run the following:

source /etc/profile.d/bash_completion.sh

And bash completion works as expected.

However, whenever I re-login, I must run the above command before bash completion starts working - it is not enabled automatically.

I have checked the permissions of the bash_completion.sh file and even added the x flag, but it is still not enabled automatically.

How can I get this working?

1 Answers

The /etc/bashrc file provided by the setup package, will source all scripts in /etc/profile.d/ by default. Also, by default your ~/.bashrc, should have the following (you can verify it's the default by looking in /etc/skel/.bashrc) :

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

Here's the relevant part (towards the end) of that file that I see on my system (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

Here's the version of setup that I'm using (and proof that that's where it comes from):

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