Skip to content

Commit 898840e

Browse files
committed
Improve PowerShell completion setup documentation
Fixes rust-lang#3128
1 parent e0ffef9 commit 898840e

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/cli/help.rs

+15-11
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ pub(crate) static DOC_HELP: &str = r"DISCUSSION:
154154
By default, it opens the documentation index. Use the various
155155
flags to open specific pieces of documentation.";
156156

157-
pub(crate) static COMPLETIONS_HELP: &str = r"DISCUSSION:
157+
pub(crate) static COMPLETIONS_HELP: &str = r#"DISCUSSION:
158158
Enable tab completion for Bash, Fish, Zsh, or PowerShell
159159
The script is output on `stdout`, allowing one to re-direct the
160160
output to the file of their choosing. Where you place the file
@@ -243,21 +243,25 @@ pub(crate) static COMPLETIONS_HELP: &str = r"DISCUSSION:
243243
244244
First, check if a profile has already been set
245245
246-
PS C:\> Test-Path $profile
246+
PS C:\> Test-Path $PROFILE
247247
248248
If the above command returns `False` run the following
249249
250-
PS C:\> New-Item -path $profile -type file -force
250+
PS C:\> New-Item -path $PROFILE -type file -force
251251
252-
Now open the file provided by `$profile` (if you used the
253-
`New-Item` command it will be
254-
`${env:USERPROFILE}\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1`
252+
Next, we save the completions file into a separate file and source it
253+
inside our profile. To do so, simply use
255254
256-
Next, we either save the completions file into our profile, or
257-
into a separate file and source it inside our profile. To save the
258-
completions into our profile simply use
255+
PS C:\> rustup completions powershell > "$(Split-Path $PROFILE)\rustup_completions.ps1"
256+
PS C:\> Write-Output ". `"`$PSScriptRoot\rustup_completions.ps1`"" >> $PROFILE
259257
260-
PS C:\> rustup completions powershell >> ${env:USERPROFILE}\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
258+
This will enable completions for the current PowerShell host. To enable
259+
them for all hosts, replace $PROFILE by $PROFILE.CurrentUserAllHosts in the
260+
above commands.
261+
262+
If you use both the Windows PowerShell powershell.exe and PowerShell Core
263+
pwsh.exe, you may have to repeat the steps above in both, as they use
264+
different profile directories.
261265
262266
CARGO:
263267
@@ -272,7 +276,7 @@ pub(crate) static COMPLETIONS_HELP: &str = r"DISCUSSION:
272276
273277
ZSH:
274278
275-
$ rustup completions zsh cargo > ~/.zfunc/_cargo";
279+
$ rustup completions zsh cargo > ~/.zfunc/_cargo"#;
276280

277281
pub(crate) static TOOLCHAIN_ARG_HELP: &str = "Toolchain name, such as 'stable', 'nightly', \
278282
or '1.8.0'. For more information see `rustup \

0 commit comments

Comments
 (0)