Bash not running script at /opt/local/etc/bash_completion.d/

Solution 1:

In order to automatically load all scripts from a directory, put this in your ~/.bashrc file

# LOAD ALL AUTOCOMPLETIONS IF ANY ARE INSTALLED
if [ -d /usr/local/etc/bash_completion.d ]; then
    for F in "/usr/local/etc/bash_completion.d/"*; do
        if [ -f "${F}" ]; then
            source "${F}";
        fi
    done
fi

Solution 2:

Yes you need to load them into your shell.

This is done by editing ~/.bashrc or ~/.bash_profile and adding the command . filename for each file. This loads the file and makes the functions available. i.e. put your source command in one of these files.

Note that you should not be adding to /opt/local/etc/bash_completion.d/ as only macports should write there. Put the files in your home directory e.g. ~/.bash_completion.d/git-completion.bash