1
1
[[ -o interactive ]] || return 0
2
2
3
3
_bash_completions_getter_path=${0: A: h} /bash-completions-getter.sh
4
+ _bash_completions_dirs=(
5
+ ${(@ s/:/ )${XDG_DATA_DIRS} }
6
+ ~ /.local/share
7
+ /data/data/com.termux/files/usr/share # Android Termux
8
+ ~ /.local/state/nix/profile/share # Nix without NixOS
9
+ /run/current-system/sw/share # NixOS
10
+ /home/linuxbrew/.linuxbrew/share # Homebrew for Linux
11
+ /opt/share # Homebrew for arm macOS
12
+ /usr/local/share # Homebrew for x86 macOS
13
+ /${MINGW_ARCH:- mingw64} /share # Windows Msys2
14
+ /usr/share
15
+ )
4
16
5
17
function _bash_completions_fallback_completer {
6
18
emulate -L zsh
@@ -63,17 +75,12 @@ function _bash_completions_fetch_supported_commands {
63
75
setopt extended_glob typeset_silent no_short_loops
64
76
unsetopt nomatch
65
77
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
78
+ local dir dirs=($BASH_COMPLETION_USER_DIR )
79
+ for dir in " ${_bash_completions_dirs[@]} " ; do
72
80
dirs+=(" $dir /bash-completion/completions" )
73
81
done
74
82
75
- dirs+=(" $bash_completions /completions" )
76
-
83
+ local c
77
84
for dir in " ${dirs[@]} " ; do
78
85
for c in " $dir " /* ; do
79
86
[ ! -f " $c " ] && continue
@@ -91,7 +98,17 @@ function _bash_completions_fetch_supported_commands {
91
98
}
92
99
93
100
function _bash_completions_load {
94
- local bash_completions=${ZSH_BASH_COMPLETIONS_FALLBACK_PATH:- ${${(@ s/:/ )${XDG_DATA_DIRS:-/ usr/ share} } [1]} / bash-completion}
101
+ local dir bash_completions
102
+ if [ -d " $ZSH_BASH_COMPLETIONS_FALLBACK_PATH " ]; then
103
+ bash_completions=$ZSH_BASH_COMPLETIONS_FALLBACK_PATH
104
+ else
105
+ for dir in " ${_bash_completions_dirs[@]} " ; do
106
+ if [ -d $dir /bash-completion ]; then
107
+ bash_completions=$dir /bash-completion
108
+ break
109
+ fi
110
+ done
111
+ fi
95
112
local reserved_words=(
96
113
" do"
97
114
" done"
0 commit comments