diff options
author | Ville Skyttä <ville.skytta@iki.fi> | 2015-09-18 11:02:29 +0300 |
---|---|---|
committer | Ville Skyttä <ville.skytta@iki.fi> | 2015-09-18 11:03:31 +0300 |
commit | c89dcbbd5510876f6304ef10806b00cc9fda19dc (patch) | |
tree | 2d55446576057c22e7fc5bbf8321fde4a5658e37 | |
parent | c5451dbd310074f8bceeada0e48e542713dada1e (diff) | |
download | bash-completion-c89dcbbd5510876f6304ef10806b00cc9fda19dc.tar.gz |
Load completions also from $XDG_DATA_DIRS (RedHat: #1264094)
-rw-r--r-- | bash_completion | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/bash_completion b/bash_completion index 58acb0a7..d768f27d 100644 --- a/bash_completion +++ b/bash_completion @@ -1958,10 +1958,20 @@ complete -F _minimal '' __load_completion() { - local cmd="$1" compdir=./completions compfile dir - [[ $BASH_SOURCE == */* ]] && compdir="${BASH_SOURCE%/*}/completions" + local -a dirs=( ${BASH_COMPLETION_USER_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion}/completions ) + local OIFS=$IFS IFS=: dir cmd="$1" compfile + for dir in ${XDG_DATA_DIRS:-/usr/local/share:/usr/share}; do + dirs+=( $dir/bash-completion/completions ) + done + IFS=$OIFS + + if [[ $BASH_SOURCE == */* ]]; then + dirs+=( "${BASH_SOURCE%/*}/completions" ) + else + dirs+=( ./completions ) + fi - for dir in ${BASH_COMPLETION_USER_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion}/completions $compdir; do + for dir in "${dirs[@]}"; do for compfile in "${cmd##*/}" "${cmd##*/}".bash _"${cmd##*/}"; do compfile="$dir/$compfile" # Avoid trying to source dirs; https://bugzilla.redhat.com/903540 |