Recommend bash-completion unless user has newer bash

This commit is contained in:
Ishan Goel 2020-07-20 18:24:01 +04:00 committed by GitHub
parent f9d77c9d89
commit 4872d6653f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,15 +23,23 @@ if type brew &>/dev/null; then
fi fi
``` ```
Should you later install the `bash-completion@2` formula, this will automatically use its initialization script to read the completions files. Should you later install the `bash-completion` formula, this will automatically use its initialization script to read the completions files.
When installed, the `bash-completion@2` formula also runs `${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh` and all files in the `bash_completion.d` directory. This is done by adding a line to your `.bash_profile` - When installed, the `bash-completion` formula also runs `${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh` and all files in the `bash_completion.d` directory. This is done by adding a line to your `.bash_profile` -
``` ```
[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh" [[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"
``` ```
which is mentioned in the Caveats section upon the installation of `bash-completion@2` which is mentioned in the Caveats section upon the installation of `bash-completion`
As both Homebrew's completion code given above and the Caveats line do the same thing, it is recommended to either not add the Caveats line or to comment the line out because Homebrew's completion code works even without installing the `bash-completion` formula.
---
**Note**
If you are using a version of `bash` newer than version 4.1 (Like Homebrew's `bash`), it is recommended to use the `bash-completion@2` formula instead as it is newer and has better performance. You can check the version of `bash` you have by running `bash --version`. MacOS ships with version 3.2.
---
As both Homebrew's completion code given above and the Caveats line do the same thing, it is recommended to either not add the Caveats line or to comment the line out because Homebrew's completion code works even without installing the `bash-completion@2` formula.
## Configuring Completions in `zsh` ## Configuring Completions in `zsh`