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,13 +1,27 @@
if which brew >/dev/null 2>&1; then
BREW_PREFIX=$(brew --prefix)
if [ -f "$BREW_PREFIX"/etc/bash_completion.d/brew ]; then
. "$BREW_PREFIX"/etc/bash_completion.d/brew
elif [ -f "$BREW_PREFIX"/Library/Contributions/brew_bash_completion.sh ]; then
. "$BREW_PREFIX"/Library/Contributions/brew_bash_completion.sh
elif [ -f "$BREW_PREFIX"/completions/bash/brew ]; then
# For the git-clone based installation, see here for more info:
# https://github.com/Bash-it/bash-it/issues/1458
# https://docs.brew.sh/Shell-Completion
. "$BREW_PREFIX"/completions/bash/brew
fi
#!/usr/bin/env bash
# Load late to make sure `system` completion loads first
# BASH_IT_LOAD_PRIORITY: 375
if [[ "$(uname -s)" != 'Darwin' ]] ; then
_log_warning "unsupported operating system - only 'Darwin' is supported"
return 0
fi
# Make sure brew is installed
_command_exists brew || return 0
BREW_PREFIX=${BREW_PREFIX:-$(brew --prefix)}
if [[ -r "$BREW_PREFIX"/etc/bash_completion.d/brew ]] ; then
source "$BREW_PREFIX"/etc/bash_completion.d/brew
elif [[ -r "$BREW_PREFIX"/Library/Contributions/brew_bash_completion.sh ]] ; then
source "$BREW_PREFIX"/Library/Contributions/brew_bash_completion.sh
elif [[ -f "$BREW_PREFIX"/completions/bash/brew ]] ; then
# For the git-clone based installation, see here for more info:
# https://github.com/Bash-it/bash-it/issues/1458
# https://docs.brew.sh/Shell-Completion
source "$BREW_PREFIX"/completions/bash/brew
fi