Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bash completion install doc improvements #3177

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 'eval -- "$("$1" completions bash)"\n' > ~/.local/share/bash-completion/completions/rustup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the value of using $1 here? It seems rather obfuscated to me.


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

# Fish
$ mkdir -p ~/.config/fish/completions
Expand Down
19 changes: 11 additions & 8 deletions src/cli/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ pub(crate) static DOC_HELP: &str = r"Discussion:
By default, it opens the documentation index. Use the various
flags to open specific pieces of documentation.";

pub(crate) static COMPLETIONS_HELP: &str = r"Discussion:
pub(crate) static COMPLETIONS_HELP: &str = r#"Discussion:
Enable tab completion for Bash, Fish, Zsh, or PowerShell
The script is output on `stdout`, allowing one to re-direct the
output to the file of their choosing. Where you place the file
Expand All @@ -169,13 +169,14 @@ pub(crate) static COMPLETIONS_HELP: &str = r"Discussion:

Bash:

Completion files are commonly stored in `/etc/bash_completion.d/` for
system-wide commands, but can be stored in
`~/.local/share/bash-completion/completions` for user-specific commands.
System wide completion files are commonly stored in
`/usr/share/bash-completion/completions`, and user-specific ones
can be stored in `~/.local/share/bash-completion/completions`.
Run the command:

$ mkdir -p ~/.local/share/bash-completion/completions
$ rustup completions bash >> ~/.local/share/bash-completion/completions/rustup
$ printf 'eval -- "$("$1" 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 +187,8 @@ 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 'eval -- "$(rustup completions bash)"\n' \
> $(brew --prefix)/etc/bash_completion.d/rustup.bash-completion

Fish:

Expand Down Expand Up @@ -270,11 +272,12 @@ pub(crate) static COMPLETIONS_HELP: &str = r"Discussion:

Bash:

$ rustup completions bash cargo >> ~/.local/share/bash-completion/completions/cargo
$ printf 'eval -- "$(rustup completions bash cargo)"\n' \
> ~/.local/share/bash-completion/completions/cargo

Zsh:

$ rustup completions zsh cargo > ~/.zfunc/_cargo";
$ rustup completions zsh cargo > ~/.zfunc/_cargo"#;

pub(crate) static OFFICIAL_TOOLCHAIN_ARG_HELP: &str =
"Toolchain name, such as 'stable', 'nightly', \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ Discussion:

Bash:

Completion files are commonly stored in `/etc/bash_completion.d/` for
system-wide commands, but can be stored in
`~/.local/share/bash-completion/completions` for user-specific commands.
System wide completion files are commonly stored in
`/usr/share/bash-completion/completions`, and user-specific ones
can be stored in `~/.local/share/bash-completion/completions`.
Run the command:

$ mkdir -p ~/.local/share/bash-completion/completions
$ rustup completions bash >> ~/.local/share/bash-completion/completions/rustup
$ printf 'eval -- "$("$1" 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 @@ -43,7 +44,8 @@ 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 'eval -- "$(rustup completions bash)"\\n' \\
> $(brew --prefix)/etc/bash_completion.d/rustup.bash-completion

Fish:

Expand Down Expand Up @@ -128,7 +130,8 @@ Discussion:

Bash:

$ rustup completions bash cargo >> ~/.local/share/bash-completion/completions/cargo
$ printf 'eval -- "$(rustup completions bash cargo)"\\n' \\
> ~/.local/share/bash-completion/completions/cargo

Zsh:

Expand Down
Loading