Skip to content

Commit 521d829

Browse files
hahnandrewakinomyogascop
authored
docs(README): update macOS docs (#1288)
Signed-off-by: Andrew Hahn <dev.andrewhahn@gmail.com> Co-authored-by: Koichi Murase <myoga.murase@gmail.com> Co-authored-by: Ville Skyttä <ville.skytta@iki.fi>
1 parent 8a8880d commit 521d829

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

README.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,36 @@ installed system wide. To do this:
6262

6363
### macOS (OS X)
6464

65-
If you're using macOS (formerly OS X), `/etc/bashrc` is apparently not sourced at
66-
all. In that case, you can put the `bash_completion` file in `/sw/etc`
67-
and add the following code to `~/.bash_profile`:
65+
If you're using macOS (formerly OS X), `/etc/bashrc` is apparently not sourced
66+
at all, and `~/.bashrc` is not sourced from `~/.bash_profile` by default
67+
(because `~/.bash_profile` is not created by default). In this case, the
68+
standard way is to configure `~/.bash_profile` to source `~/.bashrc` and write
69+
interactive settings in `~/.bashrc`. You can source `~/.bashrc` in
70+
`~/.bash_profile` in the following way:
6871

6972
```shell
70-
if [ -f /sw/etc/bash_completion ]; then
71-
. /sw/etc/bash_completion
73+
# ~/.bash_profile
74+
75+
if [[ -f ~/.bashrc ]]; then
76+
source ~/.bashrc
77+
fi
78+
```
79+
80+
Then, you can source `bash-completion` in your `~/.bashrc`. It should be noted
81+
that `bash-completion` should not be sourced in `~/.bash_profile` because
82+
`~/.bash_profile` is only loaded in interactive _login_ shell sessions. If you
83+
start nested Bash sessions, the interactive settings in `~/.bash_profile` will
84+
disappear. It is strongly recommended to source `~/.bashrc` from
85+
`~/.bash_profile` and write interactive settings in `~/.bashrc`.
86+
87+
For example, if you install `bash-completion` using Homebrew, it will install
88+
the entry point of `bash-completion` to
89+
`$HOMEBREW_PREFIX/etc/profile.d/bash_completion.sh`. We can source it by
90+
adding the following to our startup file `~/.bashrc`:
91+
92+
```shell
93+
if [[ -s $HOMEBREW_PREFIX/etc/profile.d/bash_completion.sh ]]; then
94+
. "$HOMEBREW_PREFIX/etc/profile.d/bash_completion.sh"
7295
fi
7396
```
7497

0 commit comments

Comments
 (0)