Skip to content

Commit

Permalink
Make "modern" bash completion install recipes more dynamic
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
scop committed Nov 18, 2023
1 parent 4b01c5e commit 129f159
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions doc/user-guide/src/installation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ simple as using one of the following:

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

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

# Fish
$ mkdir -p ~/.config/fish/completions
Expand Down
6 changes: 3 additions & 3 deletions src/cli/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ pub(crate) static COMPLETIONS_HELP: &str = r"Discussion:
Run the command:
$ mkdir -p ~/.local/share/bash-completion/completions
$ rustup completions bash > ~/.local/share/bash-completion/completions/rustup
$ printf '. <(rustup completions bash)\n' > ~/.local/share/bash-completion/completions/rustup
This installs the completion script. You may have to log out and
log back in to your shell session for the changes to take effect.
Expand All @@ -186,7 +186,7 @@ pub(crate) static COMPLETIONS_HELP: &str = r"Discussion:
With the `bash-completion` brew formula installed, run the command:
$ mkdir -p $(brew --prefix)/etc/bash_completion.d
$ rustup completions bash > $(brew --prefix)/etc/bash_completion.d/rustup.bash-completion
$ printf '. <(rustup completions bash)\n' > $(brew --prefix)/etc/bash_completion.d/rustup.bash-completion
Fish:
Expand Down Expand Up @@ -270,7 +270,7 @@ pub(crate) static COMPLETIONS_HELP: &str = r"Discussion:
Bash:
$ rustup completions bash cargo > ~/.local/share/bash-completion/completions/cargo
$ printf '. <(rustup completions bash cargo)\n' > ~/.local/share/bash-completion/completions/cargo
Zsh:
Expand Down

0 comments on commit 129f159

Please sign in to comment.