From 1d25d72ca8633c19cb089dff447d08c531379c59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Mon, 16 Feb 2015 22:14:58 +0200 Subject: [PATCH] Load user completions from $BASH_COMPLETION_USER_DIR/completions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fall back to XDG_DATA_HOME/bash-completion/completions or ~/.local/share/bash-completion/completions if not set. Thanks to Raphaƫl Droz. --- bash_completion | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bash_completion b/bash_completion index e707ff5f..d43075e8 100644 --- a/bash_completion +++ b/bash_completion @@ -1960,13 +1960,15 @@ complete -F _minimal '' _completion_loader() { # $1=_EmptycmD_ already for empty cmds in bash 4.3, set to it for earlier - local cmd="${1:-_EmptycmD_}" compdir=./completions compfile + local cmd="${1:-_EmptycmD_}" compdir=./completions compfile dir [[ $BASH_SOURCE == */* ]] && compdir="${BASH_SOURCE%/*}/completions" - for compfile in "${cmd##*/}" "${cmd##*/}".bash _"${cmd##*/}"; do - compfile="$compdir/$compfile" - # Avoid trying to source dirs; https://bugzilla.redhat.com/903540 - [[ -f "$compfile" ]] && . "$compfile" &>/dev/null && return 124 + for dir in ${BASH_COMPLETION_USER_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion}/completions $compdir; do + for compfile in "${cmd##*/}" "${cmd##*/}".bash _"${cmd##*/}"; do + compfile="$dir/$compfile" + # Avoid trying to source dirs; https://bugzilla.redhat.com/903540 + [[ -f "$compfile" ]] && . "$compfile" &>/dev/null && return 124 + done done # Need to define *something*, otherwise there will be no completion at all.