Skip to content

Commit

Permalink
Load completions also from $XDG_DATA_DIRS (RedHat: #1264094)
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Sep 18, 2015
1 parent c5451db commit c89dcbb
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c89dcbb

Please sign in to comment.