Files
bash-it/completion/available/system.completion.bash
John D Pell 893c8dbb96 completion/system: support $BASH_COMPLETION
Bash-completion supports pre-defining $BASH_COMPLETION as the path to the main script, so use that if it's defined.

Alsö, don't load homebrew's completion if we've successfully loaded one already.
2021-08-08 23:08:39 -04:00

26 lines
880 B
Bash
Executable File

#!/usr/bin/env bash
#
# Loads the system's Bash completion modules.
# If Homebrew is installed (OS X), it's Bash completion modules are loaded.
if [[ -r "${BASH_COMPLETION:-}" ]] ; then
source "${BASH_COMPLETION}"
elif [[ -r /etc/bash_completion ]] ; then
# shellcheck disable=SC1091
source /etc/bash_completion
# Some distribution makes use of a profile.d script to import completion.
elif [[ -r /etc/profile.d/bash_completion.sh ]] ; then
# shellcheck disable=SC1091
source /etc/profile.d/bash_completion.sh
elif [[ $OSTYPE == 'darwin'* ]] && _command_exists brew ; then
BREW_PREFIX=${BREW_PREFIX:-$(brew --prefix)}
# homebrew/versions/bash-completion2 (required for projects.completion.bash) is installed to this path
if [[ -r "$BREW_PREFIX"/etc/bash_completion ]] ; then
# shellcheck disable=SC1090
source "$BREW_PREFIX"/etc/bash_completion
fi
fi