@@ -19,11 +19,13 @@ list of operating system distributions, package names, and available versions.
19
19
Depending on the package, you may still
20
20
need to source it from either ` /etc/bashrc ` or ` ~/.bashrc ` (or any
21
21
other file sourcing those). If you have _ only_ bash >= 4.2 installed, you can
22
- do this by simply using:
22
+ do this by using:
23
23
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 ]] &&
27
29
. /usr/share/bash-completion/bash_completion
28
30
```
29
31
@@ -70,7 +72,7 @@ standard way is to configure `~/.bash_profile` to source `~/.bashrc` and write
70
72
interactive settings in ` ~/.bashrc ` . You can source ` ~/.bashrc ` in
71
73
` ~/.bash_profile ` in the following way:
72
74
73
- ``` shell
75
+ ``` bash
74
76
# ~/.bash_profile
75
77
76
78
if [[ -f ~ /.bashrc ]]; then
@@ -90,7 +92,7 @@ the entry point of `bash-completion` to
90
92
` $HOMEBREW_PREFIX/etc/profile.d/bash_completion.sh ` . We can source it by
91
93
adding the following to our startup file ` ~/.bashrc ` :
92
94
93
- ``` shell
95
+ ``` bash
94
96
if [[ -s $HOMEBREW_PREFIX /etc/profile.d/bash_completion.sh ]]; then
95
97
. " $HOMEBREW_PREFIX /etc/profile.d/bash_completion.sh"
96
98
fi
0 commit comments