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

Improve PowerShell completion setup documentation #3131

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
26 changes: 15 additions & 11 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 Down Expand Up @@ -245,21 +245,25 @@ pub(crate) static COMPLETIONS_HELP: &str = r"DISCUSSION:

First, check if a profile has already been set

PS C:\> Test-Path $profile
PS C:\> Test-Path $PROFILE

If the above command returns `False` run the following

PS C:\> New-Item -path $profile -type file -force
PS C:\> New-Item -path $PROFILE -type file -force

Now open the file provided by `$profile` (if you used the
`New-Item` command it will be
`${env:USERPROFILE}\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1`
Next, we save the completions file into a separate file and source it
inside our profile. To do so, simply use

Next, we either save the completions file into our profile, or
into a separate file and source it inside our profile. To save the
completions into our profile simply use
PS C:\> rustup completions powershell > "$(Split-Path $PROFILE)\rustup_completions.ps1"
PS C:\> Write-Output ". `"`$PSScriptRoot\rustup_completions.ps1`"" >> $PROFILE

PS C:\> rustup completions powershell >> ${env:USERPROFILE}\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
This will enable completions for the current PowerShell host. To enable
them for all hosts, replace $PROFILE by $PROFILE.CurrentUserAllHosts in the
above commands.

If you use both the Windows PowerShell powershell.exe and PowerShell Core
pwsh.exe, you may have to repeat the steps above in both, as they use
different profile directories.

CARGO:

Expand All @@ -274,7 +278,7 @@ pub(crate) static COMPLETIONS_HELP: &str = r"DISCUSSION:

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