11[[ -o interactive ]] || return 0
22
33_bash_completions_getter_path=${0: A: h} /bash-completions-getter.sh
4+ _bash_completions_dirs=(
5+ ${(@ s/:/ )${XDG_DATA_DIRS} } # in NixOS, it contains /run/current-system/sw/share
6+ ~ /.local/share
7+ /data/data/com.termux/files/usr/share # Android Termux
8+ ~ /.local/state/nix/profile/share # Nix
9+ /home/linuxbrew/.linuxbrew/share # Homebrew for Linux
10+ /opt/share # Homebrew for arm macOS
11+ /usr/local/share # Homebrew for x86 macOS
12+ /${MINGW_ARCH:- mingw64} /share # Windows Msys2
13+ /usr/share
14+ )
415
516function _bash_completions_fallback_completer {
617 emulate -L zsh
@@ -63,17 +74,12 @@ function _bash_completions_fetch_supported_commands {
6374 setopt extended_glob typeset_silent no_short_loops
6475 unsetopt nomatch
6576
66- local bash_completions=${ZSH_BASH_COMPLETIONS_FALLBACK_PATH:- ${${(@ s/:/ )${XDG_DATA_DIRS:-/ usr/ share} } [1]} / bash-completion}
67- local -a dirs=(
68- ${BASH_COMPLETION_USER_DIR:- ${XDG_DATA_HOME:- $HOME / .local/ share} / bash-completion} /completions
69- )
70-
71- for dir in ${(@ s/:/ )${XDG_DATA_DIRS:-/ usr/ local/ share:/ usr/ share} } ; do
77+ local dir dirs=($BASH_COMPLETION_USER_DIR )
78+ for dir in " ${_bash_completions_dirs[@]} " ; do
7279 dirs+=(" $dir /bash-completion/completions" )
7380 done
7481
75- dirs+=(" $bash_completions /completions" )
76-
82+ local c
7783 for dir in " ${dirs[@]} " ; do
7884 for c in " $dir " /* ; do
7985 [ ! -f " $c " ] && continue
@@ -91,7 +97,17 @@ function _bash_completions_fetch_supported_commands {
9197}
9298
9399function _bash_completions_load {
94- local bash_completions=${ZSH_BASH_COMPLETIONS_FALLBACK_PATH:- ${${(@ s/:/ )${XDG_DATA_DIRS:-/ usr/ share} } [1]} / bash-completion}
100+ local dir bash_completions
101+ if [ -d " $ZSH_BASH_COMPLETIONS_FALLBACK_PATH " ]; then
102+ bash_completions=$ZSH_BASH_COMPLETIONS_FALLBACK_PATH
103+ else
104+ for dir in " ${_bash_completions_dirs[@]} " ; do
105+ if [ -d $dir /bash-completion ]; then
106+ bash_completions=$dir /bash-completion
107+ break
108+ fi
109+ done
110+ fi
95111 local reserved_words=(
96112 " do"
97113 " done"
0 commit comments