@@ -19,11 +19,13 @@ list of operating system distributions, package names, and available versions.
1919Depending on the package, you may still
2020need to source it from either ` /etc/bashrc ` or ` ~/.bashrc ` (or any
2121other file sourcing those). If you have _ only_ bash >= 4.2 installed, you can
22- do this by simply using:
22+ do this by using:
2323
24- ``` shell
25- # Use bash-completion, if available
26- [[ $PS1 && -f /usr/share/bash-completion/bash_completion ]] && \
24+ ``` bash
25+ # Use bash-completion, if available, and avoid double-sourcing
26+ [[ $PS1 &&
27+ ! ${BASH_COMPLETION_VERSINFO:- } &&
28+ -f /usr/share/bash-completion/bash_completion ]] &&
2729 . /usr/share/bash-completion/bash_completion
2830```
2931
@@ -70,7 +72,7 @@ standard way is to configure `~/.bash_profile` to source `~/.bashrc` and write
7072interactive settings in ` ~/.bashrc ` . You can source ` ~/.bashrc ` in
7173` ~/.bash_profile ` in the following way:
7274
73- ``` shell
75+ ``` bash
7476# ~/.bash_profile
7577
7678if [[ -f ~ /.bashrc ]]; then
@@ -90,7 +92,7 @@ the entry point of `bash-completion` to
9092` $HOMEBREW_PREFIX/etc/profile.d/bash_completion.sh ` . We can source it by
9193adding the following to our startup file ` ~/.bashrc ` :
9294
93- ``` shell
95+ ``` bash
9496if [[ -s $HOMEBREW_PREFIX /etc/profile.d/bash_completion.sh ]]; then
9597 . " $HOMEBREW_PREFIX /etc/profile.d/bash_completion.sh"
9698fi
0 commit comments