system completion nitpicks

- General cleanup of system completion
- Use homebrew's completion loading script instead
- Deprecate completions covered by system
- Adjust load priority of brew to happen after system
This commit is contained in:
cornfeedhobo
2020-07-12 15:09:45 -05:00
parent 7dd5b3a67f
commit f40bfa80f1
4 changed files with 43 additions and 42 deletions

View File

@@ -1,28 +1,25 @@
#!/usr/bin/env bash
# Loads the system's Bash completion modules.
# If Homebrew is installed (OS X), its Bash completion modules are loaded.
# If Homebrew is installed (OS X), it's Bash completion modules are loaded.
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
if [[ -r /etc/bash_completion ]] ; then
# shellcheck disable=SC1091
source /etc/bash_completion
# Some distribution makes use of a profile.d script to import completion.
if [ -f /etc/profile.d/bash_completion.sh ]; then
. /etc/profile.d/bash_completion.sh
elif [[ -r /etc/profile.d/bash_completion.sh ]] ; then
# shellcheck disable=SC1091
source /etc/profile.d/bash_completion.sh
fi
if [[ "$(uname -s)" == 'Darwin' ]] && _command_exists brew ; then
BREW_PREFIX=${BREW_PREFIX:-$(brew --prefix)}
if [ $(uname) = "Darwin" ] && command -v brew &>/dev/null ; then
BREW_PREFIX=$(brew --prefix)
if [ -f "$BREW_PREFIX"/etc/bash_completion ]; then
. "$BREW_PREFIX"/etc/bash_completion
fi
# homebrew/versions/bash-completion2 (required for projects.completion.bash) is installed to this path
if [ "${BASH_VERSINFO}" -ge 4 ] && [ -f "$BREW_PREFIX"/share/bash-completion/bash_completion ]; then
export BASH_COMPLETION_COMPAT_DIR="$BREW_PREFIX"/etc/bash_completion.d
. "$BREW_PREFIX"/share/bash-completion/bash_completion
# homebrew/versions/bash-completion2 (required for projects.completion.bash) is installed to this path
if [[ -r "$BREW_PREFIX"/etc/profile.d/bash_completion.sh ]] ; then
# shellcheck disable=SC1090
source "$BREW_PREFIX"/etc/profile.d/bash_completion.sh
fi
fi