|
234 | 234 | # faster than original `bash-completion` package.
|
235 | 235 | # Read: https://superuser.com/a/1393343/496301
|
236 | 236 | #
|
237 |
| -# Note that brew recommends sourcing /usr/local/etc/profile.d/bash_completion.sh |
238 |
| -# for either version of bash-completion. These dotfiles have chosen to |
239 |
| -# explicitly look for version 2, and if found, assign a backwards-compatible |
240 |
| -# directory to look for old-style, eagerly-loaded bash completion files, then |
241 |
| -# source the new, faster ones that are non-eager. Doing so allows the old |
242 |
| -# bash-completion files to be picked up, of which there are several, including |
243 |
| -# those for git completion and vagrant completion. This works because |
244 |
| -# version 2 of bash completion checks for a `$BASH_COMPLETION_COMPAT_DIR` |
245 |
| -# variable, and if found, will immediately source all the files found under it. |
| 237 | +# It exclusively support version 2, and provide fallback support for any |
| 238 | +# utilities that have not updated, using the `$BASH_COMPLETION_COMPAT_DIR` |
| 239 | +# path. Multiple locations are searched: the usual MacOS path is first checked, |
| 240 | +# then a common path on Linux systems, like CentOS. |
246 | 241 | #
|
247 | 242 | # Additionally, the $BASH_COMPLETION_USER_FILE environment variable is set,
|
248 | 243 | # which by default points to `~/.bash_completion`, but instead has been moved to
|
249 | 244 | # an XDG directory. Note that this user file is sourced eagerly as well, so
|
250 | 245 | # should not be used, except in cases where a popular tool does not offer a
|
251 | 246 | # better alternative. For the purpose of distinguishing old-style eager
|
252 | 247 | # completions from modern non-eager completions, this user completion file
|
253 |
| -# has been added to a path under $XDG_CONFIG_HOME. Non-eager user completions |
254 |
| -# are available under the new path, under $XDG_DATA_HOME. |
| 248 | +# has been added to a path under $XDG_CONFIG_HOME. |
| 249 | +# |
| 250 | +# Non-eager user completions are available under the new path, under |
| 251 | +# $XDG_DATA_HOME. This is where all new completions should be added. |
| 252 | +export BASH_COMPLETION_USER_DIR="${XDG_DATA_HOME}/bash-completion/completions" |
255 | 253 | export BASH_COMPLETION_USER_FILE="${XDG_CONFIG_HOME}/bash-completion/bash_completion"
|
256 |
| -if [[ -e "/usr/local/share/bash-completion/bash_completion" ]]; then |
| 254 | +if [[ -e "/usr/local/etc/profile.d/bash_completion.sh" ]]; then |
257 | 255 | export BASH_COMPLETION_COMPAT_DIR="/usr/local/etc/bash_completion.d"
|
258 |
| - source "/usr/local/share/bash-completion/bash_completion" |
259 |
| -elif [[ -e "/usr/local/etc/profile.d/bash_completion.sh" ]]; then |
260 | 256 | source "/usr/local/etc/profile.d/bash_completion.sh"
|
261 |
| -elif [[ -e "/etc/bash_completion" ]]; then |
262 |
| - # This is in all certainty NOT version 2 bash completion, so pull them in |
263 |
| - # eagerly. Note that this requires sudo privileges to add a user's completion |
264 |
| - # file to /etc/bash_completion. This is really a last-ditch effort to get |
265 |
| - # v1 completion compatibility on old systems. A simple |
266 |
| - # ${HOME}/.bash_completion can also just be created, but the goal of thee |
267 |
| - # dotfiles is to follow the XDG spec as closely as possible, in an effort to |
268 |
| - # clean up the home directory. |
269 |
| - #if [[ "${BASH_COMPLETION_VERSINFO}" != "2" ]] \ |
270 |
| - # && [[ ! -e "/etc/bash_completion.d/bash_completion.${USER}" ]] \ |
271 |
| - #; then |
272 |
| - # sudo ln -s "${BASH_COMPLETION_USER_FILE}" "/etc/bash_completion.d/bash_completion.${USER}" |
273 |
| - #fi |
274 |
| - |
275 |
| - source "/etc/bash_completion" |
| 257 | +elif [[ -e "/etc/profile.d/bash_completion.sh" ]]; then |
| 258 | + export BASH_COMPLETION_COMPAT_DIR="/etc/bash_completion.d" |
| 259 | + source "/etc/profile.d/bash_completion.sh" |
276 | 260 | fi
|
277 | 261 |
|
278 | 262 | ##
|
|
0 commit comments