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} } # 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
+ )
4
15
5
16
function _bash_completions_fallback_completer {
6
17
emulate -L zsh
@@ -63,17 +74,12 @@ function _bash_completions_fetch_supported_commands {
63
74
setopt extended_glob typeset_silent no_short_loops
64
75
unsetopt nomatch
65
76
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
72
79
dirs+=(" $dir /bash-completion/completions" )
73
80
done
74
81
75
- dirs+=(" $bash_completions /completions" )
76
-
82
+ local c
77
83
for dir in " ${dirs[@]} " ; do
78
84
for c in " $dir " /* ; do
79
85
[ ! -f " $c " ] && continue
@@ -91,7 +97,17 @@ function _bash_completions_fetch_supported_commands {
91
97
}
92
98
93
99
function _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
95
111
local reserved_words=(
96
112
" do"
97
113
" done"
0 commit comments