Skip to content

Commit 129f159

Browse files
committed
Make "modern" bash completion install recipes more dynamic
The downside of installing completions in their expanded form is that they should be re-installed on respective tool updates to keep them in sync. Generating on demand fixes that, in exchange for a few milliseconds on first load. A caveat is that the use of `<( ... )` requires the shell to be in non-POSIX mode. In my opinion, POSIX mode interactive bash is too rare a creature to pass on this recipe improvement.
1 parent 4b01c5e commit 129f159

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Diff for: doc/user-guide/src/installation/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ simple as using one of the following:
7373

7474
```console
7575
# Bash
76-
$ rustup completions bash > ~/.local/share/bash-completion/completions/rustup
76+
$ printf '. <(rustup completions bash)\n' > ~/.local/share/bash-completion/completions/rustup
7777

7878
# Bash (macOS/Homebrew)
79-
$ rustup completions bash > $(brew --prefix)/etc/bash_completion.d/rustup.bash-completion
79+
$ printf '. <(rustup completions bash)\n' > $(brew --prefix)/etc/bash_completion.d/rustup.bash-completion
8080

8181
# Fish
8282
$ mkdir -p ~/.config/fish/completions

Diff for: src/cli/help.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ pub(crate) static COMPLETIONS_HELP: &str = r"Discussion:
175175
Run the command:
176176
177177
$ mkdir -p ~/.local/share/bash-completion/completions
178-
$ rustup completions bash > ~/.local/share/bash-completion/completions/rustup
178+
$ printf '. <(rustup completions bash)\n' > ~/.local/share/bash-completion/completions/rustup
179179
180180
This installs the completion script. You may have to log out and
181181
log back in to your shell session for the changes to take effect.
@@ -186,7 +186,7 @@ pub(crate) static COMPLETIONS_HELP: &str = r"Discussion:
186186
With the `bash-completion` brew formula installed, run the command:
187187
188188
$ mkdir -p $(brew --prefix)/etc/bash_completion.d
189-
$ rustup completions bash > $(brew --prefix)/etc/bash_completion.d/rustup.bash-completion
189+
$ printf '. <(rustup completions bash)\n' > $(brew --prefix)/etc/bash_completion.d/rustup.bash-completion
190190
191191
Fish:
192192
@@ -270,7 +270,7 @@ pub(crate) static COMPLETIONS_HELP: &str = r"Discussion:
270270
271271
Bash:
272272
273-
$ rustup completions bash cargo > ~/.local/share/bash-completion/completions/cargo
273+
$ printf '. <(rustup completions bash cargo)\n' > ~/.local/share/bash-completion/completions/cargo
274274
275275
Zsh:
276276

0 commit comments

Comments
 (0)